use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class DecimalValue method getDate.
/**
* The decimal is converted to a long and interpreted as the number of
* milliseconds since 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z).
* If the resulting value is out of range for a date,
* a {@link ValueFormatException} is thrown.
*/
@Override
public Calendar getDate() throws ValueFormatException {
if (value.compareTo(MIN_DATE) >= 0 && value.compareTo(MAX_DATE) <= 0) {
Calendar date = Calendar.getInstance();
date.setTimeInMillis(getLong());
return date;
} else {
throw new ValueFormatException("Decimal value is outside the date range: " + value);
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class PropertyReadMethodsTest method testGetNode.
/**
* Tests if Property.getNode() fails with ValueFormatException for
* multivalued properties.
*
* @throws RepositoryException
* @throws NotExecutableException
*/
public void testGetNode() throws RepositoryException, NotExecutableException {
Property prop = PropertyUtil.searchMultivalProp(testRootNode);
if (prop == null) {
throw new NotExecutableException("Test Property.getNode is throwing a " + "ValueFormaException not executable in case of a multivalued property.");
} else {
try {
prop.getNode();
fail("Property.getNode should throw a ValueFormatException in case of " + "a multivalued property.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class PropertyReadMethodsTest method testGetValue.
/**
* Tests failure of Property.getValue() method for a multivalue property.
*/
public void testGetValue() throws RepositoryException, NotExecutableException {
Property multiValProp = PropertyUtil.searchMultivalProp(testRootNode);
if (multiValProp != null) {
try {
multiValProp.getValue();
fail("Property.getValue() called on a multivalue property " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
} else {
throw new NotExecutableException();
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class ReferencePropertyTest method testGetDouble.
/**
* Tests failure from Reference type to Double type.
*/
public void testGetDouble() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getDouble();
fail("Conversion from a Reference value to a Double value " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class ReferencePropertyTest method testGetLong.
/**
* Tests failure of conversion from Reference type to Long type.
*/
public void testGetLong() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getLong();
fail("Conversion from a Reference value to a Long value " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
Aggregations