@Override public void containedResourceWithNoId(IParseLocation theLocation) { throw new DataFormatException("Resource has contained child resource with no ID"); }
@Override public void invalidValue(IParseLocation theLocation, String theValue, String theError) { throw new DataFormatException("Invalid attribute value \"" + theValue + "\": " + theError); }
@Override public void unknownElement(IParseLocation theLocation, String theElementName) { throw new DataFormatException("Unknown element '" + theElementName + "' found during parse"); }
@Override public void unexpectedRepeatingElement(IParseLocation theLocation, String theElementName) { throw new DataFormatException("Multiple repetitions of non-repeatable element '" + theElementName + "' found during parse"); }
@Override public void unknownReference(IParseLocation theLocation, String theReference) { throw new DataFormatException("Resource has invalid reference: " + theReference); }
@Override protected Integer parse(String theValue) { try { return Integer.parseInt(theValue); } catch (NumberFormatException e) { throw new DataFormatException(e); } }
@Override protected Boolean parse(String theValue) { if ("true".equals(theValue)) { return Boolean.TRUE; } else if ("false".equals(theValue)) { return Boolean.FALSE; } else { throw new DataFormatException("Invalid boolean string: '" + theValue + "'"); } }
protected Boolean parse(String theValue) { String value = theValue.trim(); if ("true".equals(value)) { return Boolean.TRUE; } else if ("false".equals(value)) { return Boolean.FALSE; } else { throw new DataFormatException("Invalid boolean string: '" + theValue + "'"); } }
public static String decompress(byte[] theResource) { GZIPInputStream is; try { is = new GZIPInputStream(new ByteArrayInputStream(theResource)); return IOUtils.toString(is, "UTF-8"); } catch (IOException e) { throw new DataFormatException("Failed to decompress contents", e); } }
public static byte[] compress(String theEncoded) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(os); IOUtils.write(theEncoded, gos, "UTF-8"); gos.close(); os.close(); byte[] retVal = os.toByteArray(); return retVal; } catch (IOException e) { throw new DataFormatException("Compress contents", e); } }
@Override public void incorrectJsonType(IParseLocation theLocation, String theElementName, ValueType theExpected, ScalarType theExpectedScalarType, ValueType theFound, ScalarType theFoundScalarType) { String message = LenientErrorHandler.createIncorrectJsonTypeMessage(theElementName, theExpected, theExpectedScalarType, theFound, theFoundScalarType); throw new DataFormatException(message); }
private void validatePrecisionAndThrowDataFormatException(String theValue, TemporalPrecisionEnum thePrecision) { if (isPrecisionAllowed(thePrecision) == false) { throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theValue); } }
public BaseRuntimeChildDefinition getChildByNameOrThrowDataFormatException(String theName) throws DataFormatException { validateSealed(); BaseRuntimeChildDefinition retVal = myNameToChild.get(theName); if (retVal == null) { throw new DataFormatException("Unknown child name '" + theName + "' in element " + getName() + " - Valid names are: " + new TreeSet<String>(myNameToChild.keySet())); } return retVal; }
/** * Constructor * * @throws DataFormatException * If the specified precision is not allowed for this type */ public BaseDateTimeType(Date theDate, TemporalPrecisionEnum thePrecision) { setValue(theDate, thePrecision); if (isPrecisionAllowed(thePrecision) == false) { throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theDate); } }
/** * Constructor * * @throws DataFormatException * If the specified precision is not allowed for this type */ public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision) { setValue(theDate, thePrecision); if (isPrecisionAllowed(thePrecision) == false) { throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theDate); } }
@Override public JsonLikeObject getRootObject() throws DataFormatException { if (rootType == ROOT_TYPE.OBJECT) { if (null == jsonLikeRoot) { jsonLikeRoot = new GsonJsonObject((JsonObject)nativeRoot); } return jsonLikeRoot.getAsObject(); } throw new DataFormatException("Content must be a valid JSON Object. It must start with '{'."); }
@Override public JsonLikeArray getRootArray() throws DataFormatException { if (rootType == ROOT_TYPE.ARRAY) { if (null == jsonLikeRoot) { jsonLikeRoot = new GsonJsonArray((JsonArray)nativeRoot); } return jsonLikeRoot.getAsArray(); } throw new DataFormatException("Content must be a valid JSON Array. It must start with '['."); }
private XMLEventReader createStreamReader(Reader theReader) { try { return XmlUtil.createXmlReader(theReader); } catch (FactoryConfigurationError e1) { throw new ConfigurationException("Failed to initialize STaX event factory", e1); } catch (XMLStreamException e1) { throw new DataFormatException(e1); } }
/** * Constructor * * @throws DataFormatException * If the specified precision is not allowed for this type */ public BaseDateTimeType(String theString) { setValueAsString(theString); if (isPrecisionAllowed(getPrecision()) == false) { throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + getPrecision() + " precision): " + theString); } }
private JsonLikeArray grabJsonArray(JsonLikeObject theObject, String nextName, String thePosition) { JsonLikeValue object = theObject.get(nextName); if (object == null || object.isNull()) { return null; } if (!object.isArray()) { throw new DataFormatException("Syntax error parsing JSON FHIR structure: Expected ARRAY at element '" + thePosition + "', found '" + object.getJsonType() + "'"); } return object.getAsArray(); }