Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.NamespaceRegistry


        assertThat(root.getSegmentsList().isEmpty(), is(true));
    }

    @Test
    public void shouldAlwaysReturnPathWithSingleSlashForGetString() {
        NamespaceRegistry registry = mock(NamespaceRegistry.class);
        TextEncoder encoder = mock(TextEncoder.class);
        when(encoder.encode("/")).thenReturn("/");
        assertThat(root.getString(), is("/"));
        assertThat(root.getString(registry), is("/"));
        assertThat(root.getString(registry, encoder), is("/"));
View Full Code Here


        assertThat(root.getString((TextEncoder)null), is("/"));
    }

    @Test
    public void shouldNotAllowNullTextEncoderWithNonNullNamespaceRegistry() {
        NamespaceRegistry registry = mock(NamespaceRegistry.class);
        assertThat(root.getString(registry, (TextEncoder)null), is("/"));
    }
View Full Code Here

        assertThat(root.getString(registry, (TextEncoder)null), is("/"));
    }

    @Test
    public void shouldNotAllowNullTextEncoderForDelimiterWithNonNullNamespaceRegistry() {
        NamespaceRegistry registry = mock(NamespaceRegistry.class);
        TextEncoder encoder = mock(TextEncoder.class);
        assertThat(root.getString(registry, encoder, (TextEncoder)null), is("/"));
    }
View Full Code Here

                node = session.getNodeByIdentifier(jcrValue.getString());
            } catch (RepositoryException re) {
                return false;
            }

            NamespaceRegistry namespaces = session.namespaces();
            for (int i = 0; i < constraints.length; i++) {
                try {
                    if (node.isNodeType(constraints[i].getString(namespaces))) {
                        return true;
                    }
View Full Code Here

    protected final void addAllNodesTable( ImmutableSchemata.Builder builder,
                                           ExecutionContext context,
                                           List<JcrPropertyDefinition> additionalProperties,
                                           Name[] keyPropertyNames ) {
        NamespaceRegistry registry = context.getNamespaceRegistry();
        TypeSystem typeSystem = context.getValueFactories().getTypeSystem();

        String tableName = AllNodes.ALL_NODES_NAME.name();
        boolean first = true;
        Map<String, String> typesForNames = new HashMap<String, String>();
View Full Code Here

    }

    protected final void addView( ImmutableSchemata.Builder builder,
                                  ExecutionContext context,
                                  JcrNodeType nodeType ) {
        NamespaceRegistry registry = context.getNamespaceRegistry();

        if (!nodeType.isQueryable()) {
            // The node type is defined as not queryable, so skip it ...
            return;
        }
View Full Code Here

     *
     * @param session the session; may not be null
     * @return true if the session overrides one or more namespace mappings used in this schemata, or false otherwise
     */
    private boolean overridesNamespaceMappings( JcrSession session ) {
        NamespaceRegistry registry = session.context().getNamespaceRegistry();
        if (registry instanceof LocalNamespaceRegistry) {
            Set<Namespace> localNamespaces = ((LocalNamespaceRegistry)registry).getLocalNamespaces();
            if (localNamespaces.isEmpty()) {
                // There are no local mappings ...
                return false;
            }
            for (Namespace namespace : localNamespaces) {
                if (prefixesByUris.containsKey(namespace.getNamespaceUri())) return true;
            }
            // None of the local namespace mappings overrode any namespaces used by this schemata ...
            return false;
        }
        // We can't find the local mappings, so brute-force it ...
        for (Namespace namespace : registry.getNamespaces()) {
            String expectedPrefix = prefixesByUris.get(namespace.getNamespaceUri());
            if (expectedPrefix == null) {
                // This namespace is not used by this schemata ...
                continue;
            }
View Full Code Here

        AbstractJcrNode jcrNode = CheckArg.getInstanceOf(node, AbstractJcrNode.class, "node");

        // Check the type of the node ...
        JcrNodeType nodeType = jcrNode.getPrimaryNodeType();
        if (!nodeType.getInternalName().equals(JcrNtLexicon.QUERY)) {
            NamespaceRegistry registry = session.context().getNamespaceRegistry();
            throw new InvalidQueryException(JcrI18n.notStoredQuery.text(jcrNode.path().getString(registry)));
        }

        // These are both mandatory properties for nodes of nt:query
        String statement = jcrNode.getProperty(JcrLexicon.STATEMENT).getString();
View Full Code Here

        }
    }

    @Test
    public void shouldOnlyHaveOneNamespacesNode() throws Exception {
        NamespaceRegistry registry = context.getNamespaceRegistry();

        Node rootNode = session.getRootNode();
        assertThat(rootNode, is(notNullValue()));

        Node systemNode = rootNode.getNode(JcrLexicon.SYSTEM.getString(registry));
View Full Code Here

        assertThat(namespacesNodes.getSize(), is(1L));
    }

    @Test
    public void shouldOnlyHaveOneNodeTypesNode() throws Exception {
        NamespaceRegistry registry = context.getNamespaceRegistry();

        Node rootNode = session.getRootNode();
        assertThat(rootNode, is(notNullValue()));

        Node systemNode = rootNode.getNode(JcrLexicon.SYSTEM.getString(registry));
View Full Code Here

TOP

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

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.