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


Java Path.Element方法代码示例

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


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

示例1: toDisplayPath

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * @param path Path
 * @return  display path
 */
private String toDisplayPath(Path path)
{
    StringBuffer displayPath = new StringBuffer();
    if (path.size() == 1)
    {
        displayPath.append("/");
    }
    else
    {
        for (int i = 1; i < path.size(); i++)
        {
            Path.Element element = path.get(i);
            if (element instanceof ChildAssocElement)
            {
                ChildAssociationRef assocRef = ((ChildAssocElement)element).getRef();
                NodeRef node = assocRef.getChildRef();
                displayPath.append("/");
                displayPath.append(nodeService.getProperty(node, ContentModel.PROP_NAME));
            }
        }
    }
    return displayPath.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:ACPExportPackageHandler.java

示例2: buildXPath

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
private String buildXPath(Path path)
{
    StringBuilder pathBuffer = new StringBuilder(64);
    for (Iterator<Path.Element> elit = path.iterator(); elit.hasNext(); /**/)
    {
        Path.Element element = elit.next();
        if (!(element instanceof Path.ChildAssocElement))
        {
            throw new IndexerException("Confused path: " + path);
        }
        Path.ChildAssocElement cae = (Path.ChildAssocElement) element;
        if (cae.getRef().getParentRef() != null)
        {
            pathBuffer.append("/");
            pathBuffer.append(getPrefix(cae.getRef().getQName().getNamespaceURI()));
            pathBuffer.append(ISO9075.encode(cae.getRef().getQName().getLocalName()));
        }
    }
    return pathBuffer.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:LuceneCategoryServiceImpl.java

示例3: getParents

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
private ArrayList<NodeRef> getParents(Path path)
{
    ArrayList<NodeRef> parentsInDepthOrderStartingWithSelf = new ArrayList<NodeRef>(8);
    for (Iterator<Path.Element> elit = path.iterator(); elit.hasNext(); /**/)
    {
        Path.Element element = elit.next();
        if (!(element instanceof Path.ChildAssocElement))
        {
            throw new IndexerException("Confused path: " + path);
        }
        Path.ChildAssocElement cae = (Path.ChildAssocElement) element;
        parentsInDepthOrderStartingWithSelf.add(0, tenantService.getName(cae.getRef().getChildRef()));

    }
    return parentsInDepthOrderStartingWithSelf;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ADMLuceneIndexerImpl.java

示例4: getAncestors

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
private ArrayList<NodeRef> getAncestors(Path path)
{
    ArrayList<NodeRef> ancestors = new ArrayList<NodeRef>(8);
    for (Iterator<Path.Element> elit = path.iterator(); elit.hasNext(); /**/)
    {
        Path.Element element = elit.next();
        if (!(element instanceof Path.ChildAssocElement))
        {
            throw new IndexerException("Confused path: " + path);
        }
        Path.ChildAssocElement cae = (Path.ChildAssocElement) element;
        NodeRef parentRef = cae.getRef().getParentRef();
        if(parentRef != null)
        {
            ancestors.add(0, parentRef);
        }

    }
    return ancestors;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:NodesMetaDataGet.java

示例5: getSiteName

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
public static String getSiteName(Path path) {
  //Fetching Path and preparing for rendering
  Iterator<Path.Element> pathIter = path.iterator();

  //Scan the Path to find the Alfresco Site name
  boolean siteFound = false;
  while(pathIter.hasNext()) {
    String pathElement = pathIter.next().getElementString();
    //Stripping out namespace from PathElement
    int firstChar = pathElement.lastIndexOf('}');
    if (firstChar > 0) {
      pathElement = pathElement.substring(firstChar+1);
    }
    if (pathElement.equals("sites")) {
      siteFound = true;
    } else if (siteFound) {
      return pathElement;
    }
  }
  return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-indexer,代码行数:22,代码来源:Utils.java

示例6: createIndexedPath

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Helper to convert a path into an indexed path which uniquely identifies a node
 * 
 * @param nodeRef NodeRef
 * @param path Path
 * @return Path
 */
private Path createIndexedPath(NodeRef nodeRef, Path path)
{
    // Add indexes for same name siblings
    // TODO: Look at more efficient approach
    for (int i = path.size() - 1; i >= 0; i--)
    {
        Path.Element pathElement = path.get(i);
        if (i > 0 && pathElement instanceof Path.ChildAssocElement)
        {
            int index = 1;  // for xpath index compatibility
            String searchPath = path.subPath(i).toPrefixString(namespaceService);
            List<NodeRef> siblings = searchService.selectNodes(nodeRef, searchPath, null, namespaceService, false);
            if (siblings.size() > 1)
            {
                ChildAssociationRef childAssoc = ((Path.ChildAssocElement)pathElement).getRef();
                NodeRef childRef = childAssoc.getChildRef();
                for (NodeRef sibling : siblings)
                {
                    if (sibling.equals(childRef))
                    {
                        childAssoc.setNthSibling(index);
                        break;
                    }
                    index++;
                }
            }
        }
    }
    
    return path;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:ViewXMLExporter.java

示例7: createQNamePaths

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * @return an array containing the plain qname path at index 0 and the
 *         ISO9075 element-encoded qname path at index 1
 */
private String[] createQNamePaths()
{
    final NamespaceService ns = serviceRegistry.getNamespaceService();
    final Map<String, String> cache = new HashMap<String, String>();
    final StringBuilder bufPlain = new StringBuilder(128);
    final StringBuilder bufISO9075 = new StringBuilder(128);

    final Path path = serviceRegistry.getNodeService().getPath(context.getActualNodeRef());
    for (final Path.Element e : path)
    {
        if (e instanceof Path.ChildAssocElement)
        {
            final QName qname = ((Path.ChildAssocElement) e).getRef().getQName();
            if (qname != null)
            {
                String prefix = cache.get(qname.getNamespaceURI());
                if (prefix == null)
                {
                    // first request for this namespace prefix, get and
                    // cache result
                    Collection<String> prefixes = ns.getPrefixes(qname.getNamespaceURI());
                    prefix = prefixes.size() != 0 ? prefixes.iterator().next() : "";
                    cache.put(qname.getNamespaceURI(),
                              prefix);
                }
                bufISO9075.append('/').append(prefix).append(':').append(ISO9075.encode(qname.getLocalName()));
                bufPlain.append('/').append(prefix).append(':').append(qname.getLocalName());
            }
        }
        else
        {
            bufISO9075.append('/').append(e.toString());
            bufPlain.append('/').append(e.toString());
        }
    }
    String[] qnamePaths = new String[] { bufPlain.toString(), bufISO9075.toString() };

    return qnamePaths;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:44,代码来源:AlfrescoScriptVirtualContext.java

示例8: getSiteShortName

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Returns the short name of the site this node is located within. If the 
 * node is not located within a site null is returned.
 * 
 * @return The short name of the site this node is located within, null
 *         if the node is not located within a site.
 */
public String getSiteShortName()
{
    if (!this.siteNameResolved)
    {
        this.siteNameResolved = true;
        
        Path path = this.services.getNodeService().getPath(getNodeRef());
        
        if (logger.isDebugEnabled())
            logger.debug("Determing if node is within a site using path: " + path);
        
        for (int i = 0; i < path.size(); i++)
        {
            if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
            {
                // we now know the node is in a site, find the next element in the array (if there is one)
                if ((i+1) < path.size())
                {
                    // get the site name
                    Path.Element siteName = path.get(i+1);
                 
                    // remove the "cm:" prefix and add to result object
                    this.siteName = ISO9075.decode(siteName.getPrefixedString(
                                this.services.getNamespaceService()).substring(3));
                }
              
                break;
            }
        }
    }
    
    if (logger.isDebugEnabled())
    {
        logger.debug(this.siteName != null ? 
                    "Node is in the site named \"" + this.siteName + "\"" : "Node is not in a site");
    }
    
    return this.siteName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:47,代码来源:ScriptNode.java

示例9: getSiteShortName

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Returns the short name of the site this node is located within. If the 
 * node is not located within a site null is returned.
 * 
 * @return The short name of the site this node is located within, null
 *         if the node is not located within a site.
 */
public String getSiteShortName()
{
    if (!this.siteNameResolved)
    {
        this.siteNameResolved = true;
        
        Path path = this.services.getNodeService().getPath(getNodeRef());
        
        for (int i = 0; i < path.size(); i++)
        {
            if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
            {
                // we now know the node is in a site, find the next element in the array (if there is one)
                if ((i+1) < path.size())
                {
                    // get the site name
                    Path.Element siteName = path.get(i+1);
                 
                    // remove the "cm:" prefix and add to result object
                    this.siteName = ISO9075.decode(siteName.getPrefixedString(
                                this.services.getNamespaceService()).substring(3));
                }
              
                break;
            }
        }
    }
    
    return this.siteName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:BaseContentNode.java

示例10: getDisplayPath

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Return the human readable form of the specified node Path. Fast version
 * of the method that simply converts QName localname components to Strings.
 * 
 * @param path Path to extract readable form from
 * @param showLeaf Whether to process the final leaf element of the path
 * 
 * @return human readable form of the Path
 */
public static String getDisplayPath(Path path, boolean showLeaf)
{
    // This method was moved here from org.alfresco.web.bean.repository.Repository
    StringBuilder buf = new StringBuilder(64);

    int count = path.size() - (showLeaf ? 0 : 1);
    for (int i = 0; i < count; i++)
    {
        String elementString = null;
        Path.Element element = path.get(i);
        if (element instanceof Path.ChildAssocElement)
        {
            ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
            if (elementRef.getParentRef() != null)
            {
                elementString = elementRef.getQName().getLocalName();
            }
        } else
        {
            elementString = element.getElementString();
        }

        if (elementString != null)
        {
            buf.append("/");
            buf.append(elementString);
        }
    }

    return buf.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:PathUtil.java

示例11: newPath

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
@SuppressWarnings("serial")
private Path newPath(Path parent, final String name)
{
    Path path = new Path();
    if (parent != null)
    {
        for(Path.Element element: parent)
        {
            path.append(element);
        }
    }
    path.append(new Path.Element()
    {
        @Override
        public String getElementString()
        {
            return name;
        }

        @Override
        public Element getBaseNameElement(TenantService tenantService)
        {
           return this;
        }
    });
    return path;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:NodeChangeTest.java

示例12: getPrimaryParent

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Gets the current node primary parent reference
 * 
 * @return primary parent ref
 */
public NodeRef getPrimaryParent(NodeRef nodeRef)
{
    Path primaryPath = getNodeService().getPath(nodeRef);
    Path.Element element = primaryPath.last();
    NodeRef parentRef = ((Path.ChildAssocElement) element).getRef().getParentRef();
    return parentRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:NodeBrowserPost.java

示例13: getQnamePath

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * @return QName path to this node. This can be used for Lucene PATH: style queries
 */
public String getQnamePath()
{
    if (this.qnamePath == null)
    {
        final NamespaceService ns = this.services.getNamespaceService();
        final Map<String, String> cache = new HashMap<String, String>();
        final StringBuilder buf = new StringBuilder(128);
        final Path path = this.services.getNodeService().getPath(getNodeRef());
        for (final Path.Element e : path)
        {
            if (e instanceof Path.ChildAssocElement)
            {
                final QName qname = ((Path.ChildAssocElement)e).getRef().getQName();
                if (qname != null)
                {
                    String prefix = cache.get(qname.getNamespaceURI());
                    if (prefix == null)
                    {
                        // first request for this namespace prefix, get and cache result
                        Collection<String> prefixes = ns.getPrefixes(qname.getNamespaceURI());
                        prefix = prefixes.size() != 0 ? prefixes.iterator().next() : "";
                        cache.put(qname.getNamespaceURI(), prefix);
                    }
                    buf.append('/').append(prefix).append(':').append(ISO9075.encode(qname.getLocalName()));
                }
            }
            else
            {
                buf.append('/').append(e.toString());
            }
        }
        this.qnamePath = buf.toString();
    }
    
    return this.qnamePath;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:40,代码来源:ScriptNode.java

示例14: getSiteShortName

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Returns the short name of the site this node is located within. If the node is not located within a site null is
 * returned.
 * 
 * @return The short name of the site this node is located within, null if the node is not located within a site.
 */
public String getSiteShortName(NodeRef nodeRef)
{
	String result = null;

	Path path = nodeService.getPath(nodeRef);

	if (logger.isDebugEnabled())
		logger.debug("Determing if node is within a site using path: " + path);

	for (int i = 0; i < path.size(); i++)
	{
		if ("st:sites".equals(path.get(i).getPrefixedString(namespaceService)))
		{
			// we now know the node is in a site, find the next element in the array (if there is one)
			if ((i + 1) < path.size())
			{
				// get the site name
				Path.Element siteName = path.get(i + 1);

				// remove the "cm:" prefix and add to result object
				result = ISO9075.decode(siteName.getPrefixedString(namespaceService).substring(3));
			}

			break;
		}
	}

	if (logger.isDebugEnabled())
	{
		logger.debug(result != null ? "Node is in the site named \"" + result + "\"" : "Node is not in a site");
	}

	return result;
}
 
开发者ID:skomarica,项目名称:alfresco-share-create-link,代码行数:41,代码来源:CreateLinkPost.java

示例15: getPrimaryParent

import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
 * Gets the current node primary parent reference
 * 
 * @return primary parent ref
 */
public NodeRef getPrimaryParent()
{
    getPrimaryPath();
    Path.Element element = primaryPath.last();
    NodeRef parentRef = ((Path.ChildAssocElement) element).getRef().getParentRef();
    return parentRef;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:13,代码来源:AdminNodeBrowseBean.java


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