当前位置: 首页>>代码示例>>Java>>正文


Java ValueFormatException类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:TWCable,项目名称:jackalope,代码行数:21,代码来源:ValueFactoryImpl.java

示例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;
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:26,代码来源:CardToolsImpl.java

示例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;
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:20,代码来源:ACE.java

示例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);
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:25,代码来源:ValueImpl.java

示例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);
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:23,代码来源:ValueImpl.java

示例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);
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:23,代码来源:ValueImpl.java

示例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);
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:23,代码来源:ValueImpl.java

示例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);
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:25,代码来源:ACLTest.java

示例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());
				}
			}
		}
	}
}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:26,代码来源:WebResourceGroup.java

示例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();
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:17,代码来源:PropertyToTripleTest.java

示例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();
           }
       }
}
 
开发者ID:bobpaulin,项目名称:sling-coffee,代码行数:18,代码来源:CoffeeScriptCompilerImpl.java

示例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();
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:11,代码来源:SaveDialogFormAction.java

示例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;
}
 
开发者ID:TWCable,项目名称:jackalope,代码行数:13,代码来源:NodeImpl.java

示例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()]));
}
 
开发者ID:TWCable,项目名称:jackalope,代码行数:8,代码来源:PropertyImpl.java

示例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()]));
}
 
开发者ID:TWCable,项目名称:jackalope,代码行数:8,代码来源:PropertyImpl.java


注:本文中的javax.jcr.ValueFormatException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。