本文整理汇总了Java中javax.jcr.ValueFormatException类的典型用法代码示例。如果您正苦于以下问题:Java ValueFormatException类的具体用法?Java ValueFormatException怎么用?Java ValueFormatException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueFormatException类属于javax.jcr包,在下文中一共展示了ValueFormatException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createValue
import javax.jcr.ValueFormatException; //导入依赖的package包/类
@Override
public Value createValue(String value, int type) throws ValueFormatException {
switch (type) {
case PropertyType.STRING:
return createValue(value);
case PropertyType.LONG:
return createValue(Long.valueOf(value));
case PropertyType.DOUBLE:
return createValue(Double.valueOf(value));
case PropertyType.BOOLEAN:
return createValue(Boolean.valueOf(value));
case PropertyType.DECIMAL:
return createValue(new BigDecimal(value));
case PropertyType.DATE: // TODO: parse dates
case PropertyType.BINARY:
return createValue(createBinary(value));
default:
return null;
}
}
示例2: getRealValue
import javax.jcr.ValueFormatException; //导入依赖的package包/类
public Object getRealValue(Property property) throws ValueFormatException,
RepositoryException {
Object value = null;
switch (property.getType()) {
case PropertyType.BOOLEAN:
value = property.getBoolean();
break;
case PropertyType.DATE:
value = property.getDate().getTime();
break;
case PropertyType.STRING:
value = property.getString();
break;
case PropertyType.LONG:
value = property.getLong();
break;
case PropertyType.DECIMAL:
value = property.getDecimal();
break;
default:
value = null;
}
return value;
}
示例3: getRestriction
import javax.jcr.ValueFormatException; //导入依赖的package包/类
@CheckForNull
@Override
public Value getRestriction(String restrictionName) throws RepositoryException {
for (Restriction restriction : restrictions) {
String jcrName = getJcrName(restriction);
if (jcrName.equals(restrictionName)) {
if (restriction.getDefinition().getRequiredType().isArray()) {
List<Value> values = ValueFactoryImpl.createValues(restriction.getProperty(), namePathMapper);
switch (values.size()) {
case 1: return values.get(0);
default : throw new ValueFormatException("Attempt to retrieve single value from multivalued property");
}
} else {
return ValueFactoryImpl.createValue(restriction.getProperty(), namePathMapper);
}
}
}
return null;
}
示例4: getDate
import javax.jcr.ValueFormatException; //导入依赖的package包/类
/**
* @see javax.jcr.Value#getDate()
*/
@Override
public Calendar getDate() throws RepositoryException {
try {
switch (getType()) {
case PropertyType.STRING:
case PropertyType.BINARY:
case PropertyType.DATE:
String value = propertyState.getValue(Type.DATE, index);
return Conversions.convert(value).toCalendar();
case PropertyType.LONG:
case PropertyType.DOUBLE:
case PropertyType.DECIMAL:
return Conversions.convert(propertyState.getValue(Type.LONG, index)).toCalendar();
default:
throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
}
}
catch (IllegalArgumentException e) {
throw new ValueFormatException("Error converting value to date", e);
}
}
示例5: getDecimal
import javax.jcr.ValueFormatException; //导入依赖的package包/类
/**
* @see javax.jcr.Value#getDecimal()
*/
@Override
public BigDecimal getDecimal() throws RepositoryException {
try {
switch (getType()) {
case PropertyType.STRING:
case PropertyType.BINARY:
case PropertyType.LONG:
case PropertyType.DOUBLE:
case PropertyType.DATE:
case PropertyType.DECIMAL:
return propertyState.getValue(Type.DECIMAL, index);
default:
throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
}
}
catch (IllegalArgumentException e) {
throw new ValueFormatException("Error converting value to decimal", e);
}
}
示例6: getDouble
import javax.jcr.ValueFormatException; //导入依赖的package包/类
/**
* @see javax.jcr.Value#getDouble()
*/
@Override
public double getDouble() throws RepositoryException {
try {
switch (getType()) {
case PropertyType.STRING:
case PropertyType.BINARY:
case PropertyType.LONG:
case PropertyType.DOUBLE:
case PropertyType.DATE:
case PropertyType.DECIMAL:
return propertyState.getValue(Type.DOUBLE, index);
default:
throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
}
}
catch (IllegalArgumentException e) {
throw new ValueFormatException("Error converting value to double", e);
}
}
示例7: getLong
import javax.jcr.ValueFormatException; //导入依赖的package包/类
/**
* @see javax.jcr.Value#getLong()
*/
@Override
public long getLong() throws RepositoryException {
try {
switch (getType()) {
case PropertyType.STRING:
case PropertyType.BINARY:
case PropertyType.LONG:
case PropertyType.DOUBLE:
case PropertyType.DATE:
case PropertyType.DECIMAL:
return propertyState.getValue(Type.LONG, index);
default:
throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
}
}
catch (IllegalArgumentException e) {
throw new ValueFormatException("Error converting value to long", e);
}
}
示例8: testMvRestrictions
import javax.jcr.ValueFormatException; //导入依赖的package包/类
@Test
public void testMvRestrictions() throws Exception {
ValueFactory vf = getValueFactory();
Value[] vs = new Value[] {
vf.createValue(JcrConstants.NT_FILE, PropertyType.NAME),
vf.createValue(JcrConstants.NT_FOLDER, PropertyType.NAME)
};
Map<String, Value[]> mvRestrictions = Collections.singletonMap(REP_NT_NAMES, vs);
Map<String, Value> restrictions = Collections.singletonMap(REP_GLOB, vf.createValue("/.*"));
assertTrue(acl.addEntry(testPrincipal, testPrivileges, false, restrictions, mvRestrictions));
assertFalse(acl.addEntry(testPrincipal, testPrivileges, false, restrictions, mvRestrictions));
assertEquals(1, acl.getAccessControlEntries().length);
JackrabbitAccessControlEntry ace = (JackrabbitAccessControlEntry) acl.getAccessControlEntries()[0];
try {
ace.getRestriction(REP_NT_NAMES);
fail();
} catch (ValueFormatException e) {
// success
}
Value[] vvs = ace.getRestrictions(REP_NT_NAMES);
assertArrayEquals(vs, vvs);
}
示例9: createInventory
import javax.jcr.ValueFormatException; //导入依赖的package包/类
private void createInventory(Node webResourceGroup)
throws RepositoryException, PathNotFoundException,
ValueFormatException {
if (webResourceGroup.hasNode(INVENTORY)) {
Node inventoryNode = webResourceGroup.getNode(INVENTORY);
PropertyIterator inventoryPropIt = inventoryNode.getProperties();
while (inventoryPropIt.hasNext()) {
Property currentInventoryProperty = inventoryPropIt
.nextProperty();
if (!currentInventoryProperty.getName().startsWith("jcr:")) {
String inventoryType = currentInventoryProperty.getName();
if (!inventory.containsKey(inventoryType)) {
inventory.put(inventoryType, new ArrayList<String>());
}
List<String> inventoryTypeList = inventory
.get(inventoryType);
Value[] inventoryTypeValues = currentInventoryProperty
.getValues();
for (Value currentValue : inventoryTypeValues) {
inventoryTypeList.add(currentValue.getString());
}
}
}
}
}
示例10: setUp
import javax.jcr.ValueFormatException; //导入依赖的package包/类
@Before
public void setUp() throws ValueFormatException, RepositoryException {
initMocks(this);
idTranslator = new DefaultIdentifierTranslator(mockSession);
testPropertyToTriple = new PropertyToTriple(mockSession, idTranslator);
when(mockProperty.getValue()).thenReturn(mockValue);
when(mockProperty.getParent()).thenReturn(mockNode);
when(mockProperty.getName()).thenReturn(TEST_PROPERTY_NAME);
when(mockProperty.getNamespaceURI()).thenReturn("info:");
when(mockProperty.getLocalName()).thenReturn("predicate");
when(mockProperty.getSession()).thenReturn(mockSession);
when(mockSession.getNode(TEST_NODE_PATH)).thenReturn(mockNode);
when(mockNode.getNode(TEST_NODE_PATH)).thenReturn(mockNode);
when(mockNode.getPath()).thenReturn(TEST_NODE_PATH);
testSubject = nodeToResource(idTranslator).convert(mockNode).asNode();
}
示例11: loadCoffeeScriptRunner
import javax.jcr.ValueFormatException; //导入依赖的package包/类
private void loadCoffeeScriptRunner() throws LoginException,
PathNotFoundException, RepositoryException, ValueFormatException {
ResourceResolver resolver = null;
try{
resolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
InputStream content = getCoffeeScriptJsStream(resolver);
this.scriptRunner = webResourceScriptRunnerFactory.createRunner("coffee-script.js", content);
}
finally
{
if(resolver != null)
{
resolver.close();
}
}
}
示例12: setAction
import javax.jcr.ValueFormatException; //导入依赖的package包/类
private void setAction(final Node node, Node actions, String actionName, String implClass) throws RepositoryException, PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException, ItemExistsException, AccessDeniedException {
String propName = "default" + StringUtils.capitalize(actionName);
if (node.hasProperty(propName)) {
Property defaultAction = node.getProperty(propName);
if (defaultAction.getBoolean()) {
actions.addNode(actionName, NodeTypes.ContentNode.NAME).setProperty("class", implClass);
}
defaultAction.remove();
}
}
示例13: setProperty
import javax.jcr.ValueFormatException; //导入依赖的package包/类
@Override
public Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
if (value == null) {
if (hasProperty(name))
getProperty(name).remove();
return null;
}
PropertyImpl property = getOrCreateProperty(name);
property.setValue(value);
session.changeItem(this);
return property;
}
示例14: PropertyImpl
import javax.jcr.ValueFormatException; //导入依赖的package包/类
public PropertyImpl(@Nonnull SessionImpl session, @Nonnull String path, @Nonnull String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
this(session, path);
List<Value> stringValues = new ArrayList<>(values.length);
for (String value : values)
stringValues.add(new ValueImpl(value));
setValue(stringValues.toArray(new Value[stringValues.size()]));
}
示例15: setValue
import javax.jcr.ValueFormatException; //导入依赖的package包/类
@Override
public void setValue(@Nonnull String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
List<Value> valueList = new ArrayList<>(values.length);
for (String value : values)
valueList.add(new ValueImpl(value));
setValue(valueList.toArray(new Value[valueList.size()]));
}