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


Java Property.getType方法代码示例

本文整理汇总了Java中javax.jcr.Property.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Property.getType方法的具体用法?Java Property.getType怎么用?Java Property.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.Property的用法示例。


在下文中一共展示了Property.getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import javax.jcr.Property; //导入方法依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    // First Validate
    validator.showValidation(true);
    if (validator.isValid()) {
        try {
            final Node node = item.applyChanges();
            // Set the Node name.
            setNodeName(node, item);
            // WTF was whomever at JR dev team thinking?
            for (Property prop : in((Iterator<Property>) node.getProperties())) {
                if (prop.getType() == PropertyType.STRING && StringUtils.isEmpty(prop.getValue().getString())) {
                    prop.remove();
                }
            }
            node.getSession().save();
        } catch (final RepositoryException e) {
            throw new ActionExecutionException(e);
        }
        callback.onSuccess(getDefinition().getName());
    } else {
        log.info("Validation error(s) occurred. No save performed.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:25,代码来源:SaveTemplateFormAction.java

示例2: getRealValue

import javax.jcr.Property; //导入方法依赖的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: getAttributes

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Writes the mail attributes from the <code>jamesattr:*</code> property.
 * 
 * @param node
 *            mail node
 * @param mail
 *            mail message
 * @throws RepositoryException
 *             if a repository error occurs
 * @throws IOException
 *             if an IO error occurs
 */
private void getAttributes(Node node, Mail mail) throws RepositoryException, IOException {
    PropertyIterator iterator = node.getProperties("jamesattr:*");
    while (iterator.hasNext()) {
        Property property = iterator.nextProperty();
        String name = Text.unescapeIllegalJcrChars(property.getName().substring("jamesattr:".length()));
        if (property.getType() == PropertyType.BINARY) {
            InputStream input = property.getStream();
            try {
                ObjectInputStream stream = new ObjectInputStream(input);
                mail.setAttribute(name, (Serializable) stream.readObject());
            } catch (ClassNotFoundException e) {
                throw new IOException(e.getMessage());
            } finally {
                input.close();
            }
        } else {
            mail.setAttribute(name, property.getString());
        }
    }
}
 
开发者ID:twachan,项目名称:James,代码行数:33,代码来源:JCRMailRepository.java

示例4: InertProperty

import javax.jcr.Property; //导入方法依赖的package包/类
private InertProperty(Property property)
        throws RepositoryException {
    type = property.getType();
    name = property.getName();
    values = (property.isMultiple()) ? Arrays.asList(property.getValues()) : Lists.newArrayList(property.getValue());
    nodePath = property.getParent().getPath();
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:8,代码来源:AEMConfigurationProviderImpl.java

示例5: classForJCRType

import javax.jcr.Property; //导入方法依赖的package包/类
private Class<?> classForJCRType(Property property) throws RepositoryException {
    switch (property.getType()) {
    case PropertyType.STRING:
        return String.class;
    case PropertyType.BINARY:
        return InputStream.class;
    case PropertyType.BOOLEAN:
        return Boolean.class;
    case PropertyType.LONG:
        return Long.class;
    case PropertyType.DOUBLE:
        return Double.class;
    case PropertyType.DECIMAL:
        return BigDecimal.class;
    case PropertyType.DATE:
        return Calendar.class;
    case PropertyType.NAME:
        return String.class;
    case PropertyType.PATH:
        return String.class;
    case PropertyType.REFERENCE:
        return String.class;
    case PropertyType.WEAKREFERENCE:
        return String.class;
    case PropertyType.URI:
        return String.class;
    case PropertyType.UNDEFINED:
        return String.class;
    default:
        throw new IllegalArgumentException("unknown type: " + property.getType());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:JcrProducer.java

示例6: execute

import javax.jcr.Property; //导入方法依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    // First Validate
    validator.showValidation(true);
    if (validator.isValid()) {
        try {
            final Node node = item.applyChanges();
            // Set the Node name.
            setNodeName(node, item);
            // WTF was whomever at JR dev team thinking?
            for (Property prop : in((Iterator<Property>) node.getProperties())) {
                if (prop.getType() == PropertyType.STRING && StringUtils.isEmpty(prop.getValue().getString())) {
                    prop.remove();
                }
            }
            setProperty(node, "required", item);
            setProperty(node, "type", item);

            node.getSession().save();
        } catch (final RepositoryException e) {
            throw new ActionExecutionException(e);
        }
        callback.onSuccess(getDefinition().getName());
    } else {
        log.info("Validation error(s) occurred. No save performed.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:28,代码来源:SaveFieldFormAction.java

示例7: execute

import javax.jcr.Property; //导入方法依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    // First Validate
    validator.showValidation(true);
    if (validator.isValid()) {
        try {
            final Node node = item.applyChanges();
            // Set the Node name.
            setNodeName(node, item);
            // WTF was whomever at JR dev team thinking?
            for (Property prop : in((Iterator<Property>) node.getProperties())) {
                if (prop.getType() == PropertyType.STRING && StringUtils.isEmpty(prop.getValue().getString())) {
                    prop.remove();
                }
            }
            Node actions = node.addNode("actions", NodeTypes.ContentNode.NAME);
            setAction(node, actions, "commit", "info.magnolia.ui.form.action.SaveFormActionDefinition");
            setAction(node, actions, "cancel", "info.magnolia.ui.form.action.CancelFormActionDefinition");

            Node tabs = node.addNode("form", NodeTypes.ContentNode.NAME).addNode("tabs", NodeTypes.ContentNode.NAME);
            for (Node n : in((Iterator<Node>) node.getNodes("tabs*"))) {
                if (n.hasProperty("field")) {
                    String name = n.getProperty("field").getString();

                    Node tab = tabs.addNode(Path.getUniqueLabel(tabs, Path.getValidatedLabel(name)), NodeTypes.ContentNode.NAME);
                    tab.setProperty("label", StringUtils.capitalize(name));
                    tab.addNode("fields", NodeTypes.ContentNode.NAME);
                }
                n.remove();
            }
            node.getSession().save();
        } catch (final RepositoryException e) {
            throw new ActionExecutionException(e);
        }
        callback.onSuccess(getDefinition().getName());
    } else {
        log.info("Validation error(s) occurred. No save performed.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:40,代码来源:SaveDialogFormAction.java

示例8: distill

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Extract property based on their type and return as object (of Property)
 *
 * @param property This is a property
 * @return content This is node property object
 * @throws Exception
 */
public static Object distill(Property property)
        throws Exception {
    Object content;
    boolean isMulti = property.isMultiple();
    switch (property.getType()) {
        case PropertyType.LONG:
            if (isMulti)
                content = asLongs(property);
            else
                content = property.getLong();
            break;
        case PropertyType.DECIMAL:
        case PropertyType.DOUBLE:
            if (isMulti)
                content = asDoubles(property);
            else
                content = property.getDouble();
            break;
        case PropertyType.BOOLEAN:
            if (isMulti)
                content = asBooleans(property);
            else
                content = property.getBoolean();
            break;
        case PropertyType.DATE:
            if (isMulti)
                content = asDates(property);
            else
                content = property.getValue().getString();
            break;
        case PropertyType.NAME:
        case PropertyType.STRING:
        case PropertyType.PATH:
        case PropertyType.URI:
        default:
            if (isMulti)
                content = asStrings(property);
            else
                content = property.getString();
            break;
    }
    return content;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:51,代码来源:PropertyUtils.java

示例9: setProperty

import javax.jcr.Property; //导入方法依赖的package包/类
void setProperty( final Session session,
                  final Node node,
                  final String name,
                  final Object... values ) throws Exception {
    final ValueFactory factory = session.getValueFactory();

    try {
        final boolean exists = node.hasProperty( name );

        // remove property
        if ( values == null ) {
            if ( exists ) {
                node.getProperty( name ).remove();
            } else {
                throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_REMOVE_PROPERTY_THAT_DOES_NOT_EXIST,
                                                                        name,
                                                                        node.getName() ) );
            }
        } else {
            // must be an array at this point
            final int count = values.length;

            if ( exists ) {
                final Property property = node.getProperty( name );
                final int type = property.getType();
                final boolean multiple = property.isMultiple();

                if ( count == 0 ) {
                    if ( multiple ) {
                        property.remove();
                    } else {
                        throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_REMOVE_SINGLE_VALUE_PROPERTY_WITH_EMPTY_ARRAY,
                                                                                name,
                                                                                node.getName() ) );
                    }
                } else if ( count > 1 ) {
                    if ( multiple ) {
                        setMultiValuedProperty( session, node, factory, name, values, type );
                    } else {
                        throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_SET_SINGLE_VALUE_PROPERTY_WITH_MULTIPLE_VALUES,
                                                                                name,
                                                                                node.getName() ) );
                    }
                } else {
                    // only one value so set property
                    if ( multiple ) {
                        setMultiValuedProperty( session, node, factory, name, values, type );
                    } else {
                        node.setProperty( name, ModelProperty.Util.createValue( factory, values[ 0 ] ) );
                    }
                }
            } else {
                // property does not exist and no values being set
                if ( count == 0 ) {
                    throw new ModelspaceException( ModelspaceI18n.localize( UNABLE_TO_REMOVE_PROPERTY_THAT_DOES_NOT_EXIST,
                                                                            name,
                                                                            node.getName() ) );
                }

                if ( count > 1 ) {
                    setMultiValuedProperty( session, node, factory, name, values, PropertyType.UNDEFINED );
                } else {
                    node.setProperty( name, ModelProperty.Util.createValue( factory, values[ 0 ] ) );
                }
            }
        }
    } catch ( final ConstraintViolationException | PathNotFoundException | ValueFormatException e ) {
        throw new IllegalArgumentException( e );
    }
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:71,代码来源:ModelObjectImpl.java


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