Package HTTP

Source Code of HTTP.HTMLScannerException

/*
Copyright (c) 2003-2008 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package HTTP;

import Framework.GenericException;
import Framework.ParameterHolder;
import Framework.TextData;

@SuppressWarnings("serial")
public class HTMLScannerException extends GenericException

{
    public HTMLScannerException() {
        super();
        addToMgr();
    }

    public HTMLScannerException(String pMessage) {
        super(pMessage);
        addToMgr();
    }
    public HTMLScannerException(Throwable e) {
        super(e);
        addToMgr();
    }

    public HTMLScannerException(String pMessage, int pSeverity)
    {
        super(pMessage, pSeverity);
        addToMgr();
    }

    public HTMLScannerException(String pMessage, String pDetectingMethod) {
        this(pMessage);
        this.detectingMethod = pDetectingMethod;
    }

    // ----------
    // Attributes
    // ----------
    private int charOffset;
    private int lineNumber;
    private TextData sourceLine;
    //private TextData exceptionTraceback;

    // --------------------------------
    // Accessor methods for attributes.
    // --------------------------------
    public void setCharOffset(int pValue) {
        this.charOffset = pValue;
    }

    public int getCharOffset() {
        return this.charOffset;
    }

    public void setLineNumber(int pValue) {
        this.lineNumber = pValue;
    }

    public int getLineNumber() {
        return this.lineNumber;
    }

    public void setSourceLine(TextData pValue) {
        this.sourceLine = pValue;
    }

    public TextData getSourceLine() {
        return this.sourceLine;
    }


    /**
     *  WebEntExtractErrorInfo
     * <p>
     * <p>
     * @param buffer Type: TextData
     * @param offset Type: int
     */
    public void WebEntExtractErrorInfo(TextData buffer, int offset)
    {
        //   this method extracts some key info
        //      given buffer (textdata containing html template source
        //      and offset, position where an error was detected
        //      (not necessarily buffer.offset)
        //      this method sets self.SourceLine to the text of the line
        //      containing the error,
        //      and charoffset to the relative position within the line
        //   this data can then be used later to present a better
        //   error message.
        //
        int stoffset = 0;
        int endoffset = 0;


        // -------------------------------
        // Parameters for call to FindLine
        // -------------------------------
        ParameterHolder qq_StartOffset = new ParameterHolder(stoffset);
        ParameterHolder qq_EndOffset = new ParameterHolder(endoffset);
        boolean qq_FindLine = buffer.findLine(buffer.getLineNumber(offset), qq_StartOffset, qq_EndOffset);
        stoffset = qq_StartOffset.getInt();
        endoffset = qq_EndOffset.getInt();

        if (qq_FindLine) {
            this.sourceLine = buffer.copyRange(stoffset, endoffset);
            this.charOffset = offset-stoffset;
            this.lineNumber = buffer.getLineNumber(offset);
        }
        else {
            this.sourceLine = new TextData("Unavailable");
            this.charOffset = 0;
        }
    }

// end class HTMLScannerException
TOP

Related Classes of HTTP.HTMLScannerException

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.