Java Code Examples for org.xmlpull.v1.XmlPullParserException#getMessage()

The following examples show how to use org.xmlpull.v1.XmlPullParserException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EXIPullParser.java    From exificient with MIT License 6 votes vote down vote up
public String getText() {
	try {
		switch (getEventType()) {
		case XmlPullParser.TEXT:
			return characters.toString();
		case XmlPullParser.COMMENT:
			return new String(comment);
		case XmlPullParser.ENTITY_REF:
			return new String(this.entityReference);
		case XmlPullParser.DOCDECL:
			return getDocTypeString();
		default:
			throw new RuntimeException("Unexpected event, id="
					+ getEventType());
		}
	} catch (XmlPullParserException e) {
		throw new RuntimeException("Unexpected text, error="
				+ e.getMessage());
	}
}
 
Example 2
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Parse content that is known to be a resource
 * @ 
 */
@Override
public Resource parse(InputStream input) throws IOException, FHIRFormatError {
	try {
		XmlPullParser xpp = loadXml(input);
		return parse(xpp);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 3
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public DataType parseType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
	try {
		XmlPullParser xml = loadXml(input);
		return parseType(xml, knownType);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 4
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public DataType parseAnyType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
  try {
    XmlPullParser xml = loadXml(input);
    return parseAnyType(xml, knownType);
  } catch (XmlPullParserException e) {
    throw new FHIRFormatError(e.getMessage(), e);
  }
}
 
Example 5
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Parse content that is known to be a resource
 * @ 
 */
@Override
public Resource parse(InputStream input) throws IOException, FHIRFormatError {
	try {
		XmlPullParser xpp = loadXml(input);
		return parse(xpp);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 6
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public Type parseType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
	try {
		XmlPullParser xml = loadXml(input);
		return parseType(xml, knownType);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 7
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public Type parseAnyType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
  try {
    XmlPullParser xml = loadXml(input);
    return parseAnyType(xml, knownType);
  } catch (XmlPullParserException e) {
    throw new FHIRFormatError(e.getMessage(), e);
  }
}
 
Example 8
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Parse content that is known to be a resource
 * @ 
 */
@Override
public Resource parse(InputStream input) throws IOException, FHIRFormatError {
	try {
		XmlPullParser xpp = loadXml(input);
		return parse(xpp);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 9
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public Type parseType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
	try {
		XmlPullParser xml = loadXml(input);
		return parseType(xml, knownType);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 10
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Parse content that is known to be a resource
 * @ 
 */
@Override
public Resource parse(InputStream input) throws IOException, FHIRFormatError {
	try {
		XmlPullParser xpp = loadXml(input);
		return parse(xpp);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 11
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public Type parseType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
	try {
		XmlPullParser xml = loadXml(input);
		return parseType(xml, knownType);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 12
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Parse content that is known to be a resource
 * @ 
 */
@Override
public Resource parse(InputStream input) throws IOException, FHIRFormatError {
	try {
		XmlPullParser xpp = loadXml(input);
		return parse(xpp);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 13
Source File: XmlParserBase.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public Type parseType(InputStream input, String knownType) throws IOException, FHIRFormatError  {
	try {
		XmlPullParser xml = loadXml(input);
		return parseType(xml, knownType);
	} catch (XmlPullParserException e) {
		throw new FHIRFormatError(e.getMessage(), e);
	}
}
 
Example 14
Source File: DocumentBuilderImpl.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Override
public Document parse(InputSource source) throws SAXException, IOException {
    if (source == null) {
        throw new IllegalArgumentException("source == null");
    }

    String namespaceURI = null;
    String qualifiedName = null;
    DocumentType doctype = null;
    String inputEncoding = source.getEncoding();
    String systemId = source.getSystemId();
    DocumentImpl document = new DocumentImpl(
            dom, namespaceURI, qualifiedName, doctype, inputEncoding);
    document.setDocumentURI(systemId);

    KXmlParser parser = new KXmlParser();
    try {
        parser.keepNamespaceAttributes();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, namespaceAware);

        if (source.getByteStream() != null) {
            parser.setInput(source.getByteStream(), inputEncoding);
        } else if (source.getCharacterStream() != null) {
            parser.setInput(source.getCharacterStream());
        } else if (systemId != null) {
            URL url = new URL(systemId);
            URLConnection urlConnection = url.openConnection();
            urlConnection.connect();
            // TODO: if null, extract the inputEncoding from the Content-Type header?
            parser.setInput(urlConnection.getInputStream(), inputEncoding);
        } else {
            throw new SAXParseException("InputSource needs a stream, reader or URI", null);
        }

        if (parser.nextToken() == XmlPullParser.END_DOCUMENT) {
            throw new SAXParseException("Unexpected end of document", null);
        }

        parse(parser, document, document, XmlPullParser.END_DOCUMENT);

        parser.require(XmlPullParser.END_DOCUMENT, null, null);
    } catch (XmlPullParserException ex) {
        if (ex.getDetail() instanceof IOException) {
            throw (IOException) ex.getDetail();
        }
        if (ex.getDetail() instanceof RuntimeException) {
            throw (RuntimeException) ex.getDetail();
        }

        LocatorImpl locator = new LocatorImpl();

        locator.setPublicId(source.getPublicId());
        locator.setSystemId(systemId);
        locator.setLineNumber(ex.getLineNumber());
        locator.setColumnNumber(ex.getColumnNumber());

        SAXParseException newEx = new SAXParseException(ex.getMessage(), locator);

        if (errorHandler != null) {
            errorHandler.error(newEx);
        }

        throw newEx;
    } finally {
        IoUtils.closeQuietly(parser);
    }

    return document;
}