Search in sources :

Example 6 with XmlParseException

use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.

the class XmlPullReader method parse.

public synchronized void parse(InputStream is, String enc) throws XmlParseException, IOException {
    if (is == null) {
        throw new NullPointerException("InputStream");
    }
    try {
        XmlPullParser parser = createParser();
        parser.setInput(is, enc);
        parse(parser);
    } catch (XmlPullParserException e) {
        throw new XmlParseException(getParser(), e.getMessage());
    }
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) XmlParseException(org.openforis.idm.metamodel.xml.XmlParseException)

Example 7 with XmlParseException

use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.

the class SurveyUnmarshaller method readNamepaceDeclarations.

protected void readNamepaceDeclarations() throws XmlParseException {
    XmlPullParser pp = getParser();
    try {
        int nsCount = pp.getNamespaceCount(1);
        for (int i = 0; i < nsCount; i++) {
            String prefix = pp.getNamespacePrefix(i);
            if (prefix != null) {
                String uri = pp.getNamespaceUri(i);
                survey.addCustomNamespace(uri, prefix);
            }
        }
    } catch (XmlPullParserException e) {
        throw new XmlParseException(pp, "Failed to read namespace declarations", e);
    }
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) XmlParseException(org.openforis.idm.metamodel.xml.XmlParseException)

Example 8 with XmlParseException

use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.

the class TextAttributeDefinitionPR method onStartDefinition.

@Override
protected void onStartDefinition() throws XmlParseException, XmlPullParserException, IOException {
    super.onStartDefinition();
    String typeStr = getAttribute(TYPE, false);
    TextAttributeDefinition defn = (TextAttributeDefinition) getDefinition();
    try {
        defn.setType(typeStr == null ? Type.SHORT : Type.valueOf(typeStr.toUpperCase()));
    } catch (IllegalArgumentException e) {
        throw new XmlParseException(getParser(), "invalid type " + typeStr);
    }
}
Also used : TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) XmlParseException(org.openforis.idm.metamodel.xml.XmlParseException)

Example 9 with XmlParseException

use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.

the class XmlPullReader method parse.

protected synchronized void parse(XmlPullParser parser) throws XmlParseException, IOException {
    try {
        parser.nextTag();
        parseElement(parser);
    } catch (XmlPullParserException e) {
        throw new XmlParseException(parser, e.getMessage(), e);
    }
}
Also used : XmlPullParserException(org.xmlpull.v1.XmlPullParserException) XmlParseException(org.openforis.idm.metamodel.xml.XmlParseException)

Aggregations

XmlParseException (org.openforis.idm.metamodel.xml.XmlParseException)9 XmlPullParser (org.xmlpull.v1.XmlPullParser)5 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)4 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)1 UITabSetPR (org.openforis.collect.persistence.xml.internal.unmarshal.UITabSetPR)1 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)1 Type (org.openforis.idm.metamodel.NumericAttributeDefinition.Type)1 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)1