Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.NameFactory


    public void setRequiredPrimaryTypeNames( String[] requiredPrimaryTypes ) throws ConstraintViolationException {
        if (requiredPrimaryTypes == null) {
            throw new ConstraintViolationException(JcrI18n.badNodeTypeName.text("requiredPrimaryTypes"));
        }

        NameFactory nameFactory = getContext().getValueFactories().getNameFactory();
        Name[] rpts = new Name[requiredPrimaryTypes.length];
        for (int i = 0; i < requiredPrimaryTypes.length; i++) {
            try {
                rpts[i] = nameFactory.create(requiredPrimaryTypes[i]);
            } catch (ValueFormatException vfe) {
                throw new ConstraintViolationException(vfe);
            }
        }
View Full Code Here


     *         type permission}.
     * @throws RepositoryException if any other error occurs
     */
    public void unregisterNodeTypes( Collection<String> nodeTypeNames )
        throws NoSuchNodeTypeException, InvalidNodeTypeDefinitionException, RepositoryException {
        NameFactory nameFactory = context().getValueFactories().getNameFactory();

        try {
            session.checkWorkspacePermission(session.workspaceName(), ModeShapePermissions.REGISTER_TYPE);
        } catch (AccessControlException ace) {
            throw new AccessDeniedException(ace);
        }

        Collection<Name> names = new ArrayList<Name>(nodeTypeNames.size());
        for (String name : nodeTypeNames) {
            names.add(nameFactory.create(name));
        }

        // Unregister the node types, but perform a check to see if any of the node types are currently being used.
        // Unregistering a node type that is being used will likely cause the system to become unstable.
        boolean failIfNodeTypesAreUsed = true;
View Full Code Here

                                  String primaryTypeName,
                                  String[] mixinNames ) throws RepositoryException {
        CheckArg.isNotEmpty(testTypeNames, "testTypeNames");
        CheckArg.isNotEmpty(primaryTypeName, "primaryTypeName");

        NameFactory nameFactory = context().getValueFactories().getNameFactory();
        Name[] typeNames = nameFactory.create(testTypeNames);

        // first check primary type
        for (Name typeName : typeNames) {
            JcrNodeType nodeType = getNodeType(typeName);
View Full Code Here

                        PathFactory pathFactory = factories().getPathFactory();
                        Path thisPathValue = pathFactory.create(this.value);
                        Path thatPathValue = pathFactory.create(that.value);
                        return thisPathValue.equals(thatPathValue);
                    case PropertyType.NAME:
                        NameFactory nameFactory = factories().getNameFactory();
                        Name thisNameValue = nameFactory.create(this.value);
                        Name thatNameValue = nameFactory.create(that.value);
                        return thisNameValue.equals(thatNameValue);
                    case PropertyType.REFERENCE:
                    case PropertyType.WEAKREFERENCE:
                    case org.modeshape.jcr.api.PropertyType.SIMPLE_REFERENCE:
                        return this.getString().equals(that.getString());
View Full Code Here

        protected ReferenceConstraintChecker( String[] valueConstraints,
                                              ExecutionContext context ) {
            this.context = context;

            NameFactory factory = context.getValueFactories().getNameFactory();

            constraints = new Name[valueConstraints.length];

            for (int i = 0; i < valueConstraints.length; i++) {
                constraints[i] = factory.create(valueConstraints[i]);
            }
        }
View Full Code Here

        if (line.length() == 0) return null; // blank line
        char firstChar = line.charAt(0);
        if (firstChar == '#') return null; // comment line
        if (firstChar == ' ') return null; // ignore line
        Matcher matcher = PROPERTY_PATTERN.matcher(line);
        NameFactory nameFactory = factories.getNameFactory();
        if (!matcher.matches()) {
            // It should be an empty multi-valued property, and the line consists only of the name ...
            Name name = nameFactory.create(decoder.decode(line));
            return propertyFactory.create(name);
        }

        String nameString = decoder.decode(matcher.group(1));
        String typeString = matcher.group(2);
        String valuesString = matcher.group(4);

        Name name = null;
        try {
            name = factories.getNameFactory().create(nameString);
        } catch (ValueFormatException e) {
            // See MODE-1281. Earlier versions would write out an empty property without the trailing line feed,
            // so we need to consider this case now. About the only thing we can do is look for two namespace-prefixed names
            // ...
            if (nameString.indexOf(':') < nameString.lastIndexOf(':')) {
                // This is likely two names smashed together. Use the namespace prefixes to look for where we can break this
                // ...
                Set<String> prefixes = new LinkedHashSet<String>();
                prefixes.add(JcrLexicon.Namespace.PREFIX);
                for (String prefix : registry.getPrefixes()) {
                    prefixes.add(prefix);
                }
                for (String prefix : prefixes) {
                    int index = nameString.lastIndexOf(prefix + ":");
                    if (index <= 0) continue;
                    // Otherwise, we found a match. Parse the first property name, and create an empty property ...
                    name = nameFactory.create(nameString.substring(0, index));
                    result.put(name, propertyFactory.create(name));
                    // Now parse the name of the next property and continue ...
                    name = nameFactory.create(nameString.substring(index));
                    break;
                }
            } else {
                throw e;
            }
View Full Code Here

                                            NodeTypes.Supplier nodeTypesSupplier,
                                            IndexDefinition indexDefinition,
                                            SingleColumnIndexOperations operations ) {
        assert indexDefinition.hasSingleColumn();
        String processKey = context.getProcessId();
        NameFactory names = context.getValueFactories().getNameFactory();
        Name nodeTypeName = names.create(indexDefinition.getNodeTypeName());
        Name propName = names.create(indexDefinition.getColumnDefinition(0).getPropertyName());
        return new SinglePropertyIndexChangeSetListener(processKey, nodeTypesSupplier, nodeTypeName, propName, operations);
    }
View Full Code Here

                                            NodeTypes.Supplier nodeTypesSupplier,
                                            IndexDefinition indexDefinition,
                                            MultiColumnIndexOperations operations ) {
        assert indexDefinition.hasSingleColumn();
        String processKey = context.getProcessId();
        NameFactory names = context.getValueFactories().getNameFactory();
        Name nodeTypeName = names.create(indexDefinition.getNodeTypeName());
        Name[] propNames = new Name[indexDefinition.size()];
        for (int i = 0; i != indexDefinition.size(); ++i) {
            propNames[i] = names.create(indexDefinition.getColumnDefinition(i).getPropertyName());
        }
        return new MultiPropertyIndexChangeSetListener(processKey, nodeTypesSupplier, nodeTypeName, propNames, operations);
    }
View Full Code Here

    @Override
    public Name getPrimaryType( NodeCache cache ) {
        AbstractSessionCache session = session(cache);
        Property prop = getProperty(JcrLexicon.PRIMARY_TYPE, session);
        NameFactory nameFactory = session.nameFactory();
        return prop != null ? nameFactory.create(prop.getFirstValue()) : nameFactory.create((Object)null);
    }
View Full Code Here

        MixinChanges changes = mixinChanges(false);
        if (prop == null || prop.size() == 0) {
            return changes != null ? changes.getAdded() : Collections.<Name>emptySet();
        }

        final NameFactory nameFactory = session.nameFactory();
        if (prop.size() == 1) {
            Name name = nameFactory.create(prop.getFirstValue());
            if (changes == null) return Collections.singleton(name);
            Set<Name> all = new HashSet<Name>(changes.getAdded());
            all.add(name);
            all.removeAll(changes.getRemoved());
            return all;
        }
        Set<Name> names = new HashSet<Name>();
        for (Object value : prop) {
            Name name = nameFactory.create(value);
            if (changes == null || !changes.getRemoved().contains(name)) names.add(name);
        }
        if (changes != null) names.addAll(changes.getAdded());
        return names;
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.value.NameFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.