use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.
the class UIOptionsBinder method unmarshalTabSet.
private UITabSet unmarshalTabSet(XmlPullParser parser, UIOptions uiOptions) throws IOException, XmlPullParserException, XmlParseException {
try {
UITabSetPR tabSetPR = new UITabSetPR(this, uiOptions);
tabSetPR.parse(parser);
UITabSet tabSet = tabSetPR.getTabSet();
return tabSet;
} catch (XmlParseException e) {
if (parser != null && parser.getEventType() == XmlPullParser.END_DOCUMENT) {
return null;
} else {
throw e;
}
}
}
use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.
the class NumericAttributeDefinitionPR method onStartDefinition.
@Override
protected void onStartDefinition() throws XmlParseException, XmlPullParserException, IOException {
super.onStartDefinition();
String typeStr = getAttribute(TYPE, false);
NumericAttributeDefinition defn = (NumericAttributeDefinition) getDefinition();
try {
Type type = typeStr == null ? Type.REAL : Type.valueOf(typeStr.toUpperCase());
defn.setType(type);
} catch (IllegalArgumentException e) {
throw new XmlParseException(getParser(), "unknown type " + typeStr);
}
}
use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.
the class XmlPullReader method readElement.
protected void readElement(XmlSerializer out, boolean includeOuterTag) throws XmlParseException, XmlPullParserException, IOException {
XmlPullParser in = getParser();
if (in.getEventType() != START_TAG) {
throw new XmlParseException(in, "start tag expected");
}
if (out != null && includeOuterTag) {
out.startTag(in.getNamespace(), in.getName());
}
int depth = 1;
while (depth != 0) {
switch(in.next()) {
case START_TAG:
if (out != null) {
out.setPrefix("", in.getNamespace());
out.startTag(in.getNamespace(), in.getName());
for (int i = 0; i < in.getAttributeCount(); i++) {
String attributeNamespace = in.getAttributeNamespace(i);
String attributeName = in.getAttributeName(i);
String attributeValue = in.getAttributeValue(i);
out.attribute(attributeNamespace, attributeName, attributeValue);
}
}
depth++;
break;
case END_TAG:
if (out != null && (includeOuterTag || depth > 1)) {
out.endTag(in.getNamespace(), in.getName());
}
depth--;
break;
case TEXT:
if (out != null) {
out.text(in.getText());
}
break;
case CDSECT:
if (out != null) {
out.cdsect(in.getText());
}
break;
case ENTITY_REF:
if (out != null) {
out.entityRef(in.getText());
}
break;
}
}
if (out != null) {
out.flush();
}
}
use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.
the class XmlPullReader method getAttribute.
protected String getAttribute(String attr, boolean required) throws XmlParseException {
XmlPullParser parser = getParser();
String value = getAttributeValue(parser, namespace, attr);
if (required && (value == null || value.isEmpty())) {
throw new XmlParseException(parser, "missing required attribute " + attr);
}
return value;
}
use of org.openforis.idm.metamodel.xml.XmlParseException in project collect by openforis.
the class XmlPullReader method parse.
public synchronized void parse(Reader reader) throws XmlParseException, IOException {
try {
XmlPullParser parser = createParser();
parser.setInput(reader);
parse(parser);
} catch (XmlPullParserException e) {
throw new XmlParseException(getParser(), e.getMessage(), e);
}
}
Aggregations