Java Code Examples for org.alfresco.service.namespace.NamespacePrefixResolver#getNamespaceURI()

The following examples show how to use org.alfresco.service.namespace.NamespacePrefixResolver#getNamespaceURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String matchURI(String prefix, NamespacePrefixResolver namespacePrefixResolver)
{
    HashSet<String> prefixes = new HashSet<String>(namespacePrefixResolver.getPrefixes());
    if (prefixes.contains(prefix))
    {
        return namespacePrefixResolver.getNamespaceURI(prefix);
    }
    String match = null;
    for (String candidate : prefixes)
    {
        if (candidate.equalsIgnoreCase(prefix))
        {
            if (match == null)
            {
                match = candidate;
            }
            else
            {

                throw new QueryModelException("Ambiguous namespace prefix " + prefix);

            }
        }
    }
    if (match == null)
    {
        return null;
    }
    else
    {
        return namespacePrefixResolver.getNamespaceURI(match);
    }
}
 
Example 2
Source File: SortedResultSet.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private QName expandAttributeFieldName(String field, NamespacePrefixResolver namespacePrefixResolver)
{
    QName qname;
    // Check for any prefixes and expand to the full uri
    if (field.charAt(1) != '{')
    {
        int colonPosition = field.indexOf(':');
        if (colonPosition == -1)
        {
            // use the default namespace
            qname = QName.createQName(NamespaceService.DEFAULT_URI, field.substring(1));
        }
        else
        {
            String prefix = field.substring(1, colonPosition);

            String uri = namespacePrefixResolver.getNamespaceURI(prefix);
            if (uri == null)
            {
                return null;
            }

            // find the prefix
            qname = QName.createQName(prefix, field.substring(colonPosition + 1), namespacePrefixResolver);
        }
    }
    else
    {
        qname = QName.createQName(field.substring(1));
    }
    return qname;
}
 
Example 3
Source File: QueryParserUtils.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String matchURI(NamespacePrefixResolver namespacePrefixResolver, String prefix)
{
    HashSet<String> prefixes = new HashSet<String>(namespacePrefixResolver.getPrefixes());
    if (prefixes.contains(prefix))
    {
        return namespacePrefixResolver.getNamespaceURI(prefix);
    }
    String match = null;
    for (String candidate : prefixes)
    {
        if (candidate.equalsIgnoreCase(prefix))
        {
            if (match == null)
            {
                match = candidate;
            }
            else
            {

                throw new NamespaceException("Ambiguous namespace prefix " + prefix);

            }
        }
    }
    if (match == null)
    {
        return null;
    }
    else
    {
        return namespacePrefixResolver.getNamespaceURI(match);
    }
}