List of usage examples for org.apache.commons.collections Transformer Transformer
Transformer
From source file:org.jahia.services.render.URLGenerator.java
@SuppressWarnings("unchecked") public Map<String, String> getTemplateTypes() { if (templateTypes == null) { templateTypes = LazyMap.decorate(new HashMap<String, String>(), new Transformer() { public Object transform(Object templateType) { return getTemplateType((String) templateType); }//from ww w .j ava2 s . co m }); } return templateTypes; }
From source file:org.jahia.services.render.URLGenerator.java
@SuppressWarnings("unchecked") public Map<String, String> getBases() { if (bases == null) { bases = LazyMap.decorate(new HashMap<String, String>(), new Transformer() { public Object transform(Object lang) { return getBase((String) lang); }//from www .j ava 2 s . c o m }); } return bases; }
From source file:org.jahia.services.search.JCRNodeHit.java
@SuppressWarnings("unchecked") public Map<String, JCRPropertyWrapper> getProperties() { if (propertiesFacade == null) { propertiesFacade = LazyMap.decorate(new HashMap<String, String>(), new Transformer() { private Map<Object, JCRPropertyWrapper> accessedProperties = new HashMap<Object, JCRPropertyWrapper>(); public Object transform(Object input) { JCRPropertyWrapper property = null; if (accessedProperties.containsKey(input)) { property = accessedProperties.get(input); } else { try { property = resource.getProperty(String.valueOf(input)); } catch (RepositoryException e) { logger.warn("Error accessing property '" + input + "'.", e); }// ww w .j a va2 s . c o m accessedProperties.put(input, property); } return property; } }); } return propertiesFacade; }
From source file:org.jahia.services.templates.JahiaTemplateManagerService.java
/** * Returns the lookup map for template packages by the JCR node name. * * @return the lookup map for template packages by the JCR node name *//*from w w w .ja v a 2 s.c om*/ @SuppressWarnings("unchecked") public Map<String, JahiaTemplatesPackage> getTemplatePackageByNodeName() { return LazyMap.decorate(new HashMap<String, JahiaTemplatesPackage>(), new Transformer() { @Override public Object transform(Object input) { return templatePackageRegistry.lookupById(String.valueOf(input)); } }); }
From source file:org.jahia.utils.osgi.parsers.cnd.JahiaCndReader.java
public void getDefinitionsAndReferences(Set<String> contentTypeDefinitions, Set<String> contentTypeReferences) throws RepositoryException { for (ExtendedNodeType extendedNodeType : getNodeTypesList()) { getLog().debug(filename + " Nodetype definition " + extendedNodeType.getName()); contentTypeDefinitions.add(extendedNodeType.getName()); for (String superTypeName : extendedNodeType.getDeclaredSupertypeNames()) { getLog().debug(filename + " node type super type reference " + superTypeName); contentTypeReferences.add(superTypeName); }/*from ww w .j a v a 2 s .co m*/ for (String mixinExtendName : extendedNodeType.getMixinExtendNames()) { getLog().debug(filename + " node type mixin type reference " + mixinExtendName); contentTypeReferences.add(mixinExtendName); } ExtendedNodeDefinition[] childNodeDefinitions = extendedNodeType.getDeclaredChildNodeDefinitions(); for (ExtendedNodeDefinition childNodeDefinition : childNodeDefinitions) { if (childNodeDefinition.getDefaultPrimaryTypeName() != null) { getLog().debug(filename + " child node default type reference " + childNodeDefinition.getDefaultPrimaryTypeName()); contentTypeReferences.add(childNodeDefinition.getDefaultPrimaryTypeName()); } String[] requiredPrimaryTypeNames = childNodeDefinition.getRequiredPrimaryTypeNames(); for (String requiredPrimaryTypeName : requiredPrimaryTypeNames) { getLog().debug(filename + " child node required type reference " + requiredPrimaryTypeName); contentTypeReferences.add(requiredPrimaryTypeName); } Map<String, String> selectorOptions = childNodeDefinition.getSelectorOptions(); if (selectorOptions.size() > 0) { getLog().debug(filename + "Found child node selector options !!!!!!!!!!!!!!!!!!"); } } ExtendedPropertyDefinition[] propertyDefinitions = extendedNodeType.getPropertyDefinitions(); for (ExtendedPropertyDefinition propertyDefinition : propertyDefinitions) { if (ExtendedPropertyType.REFERENCE == propertyDefinition.getRequiredType() || ExtendedPropertyType.WEAKREFERENCE == propertyDefinition.getRequiredType()) { String[] valueConstraints = propertyDefinition.getValueConstraints(); for (String valueConstraint : valueConstraints) { if (valueConstraint != null) { getLog().debug(filename + " reference property value contraints " + valueConstraint); contentTypeReferences.add(valueConstraint); } } Value[] defaultValues = propertyDefinition.getDefaultValues(); for (Value defaultValue : defaultValues) { if (defaultValue != null) { getLog().debug(filename + " found reference property default value " + defaultValue.getString()); contentTypeReferences.add(defaultValue.getString()); } } } Map<String, String> selectorOptions = propertyDefinition.getSelectorOptions(); if (selectorOptions.size() > 0) { if (selectorOptions.containsKey("nodes")) { String nodeSelector = selectorOptions.get("nodes"); for (String nodeSelectorItem : Pattern.compile("|", Pattern.LITERAL).split(nodeSelector)) { String[] nodeSelectorOptions = nodeSelectorItem.split(";"); if (nodeSelectorOptions.length > 1) { if (StringUtils.isNotEmpty(nodeSelectorOptions[1])) { getLog().debug( filename + " found choicelist node type " + nodeSelectorOptions[1]); contentTypeReferences.add(nodeSelectorOptions[1]); } } } } if (selectorOptions.containsKey("nodetypes")) { String param = selectorOptions.get("nodetypes"); if (param.indexOf(";fromDependencies") > -1) { } if (param.startsWith("MIXIN")) { } else if (param.startsWith("PRIMARY")) { } else if (param.startsWith("ALL")) { } else if (StringUtils.isEmpty(param)) { } else { getLog().debug(filename + " found choicelist nodetype type " + param); contentTypeReferences.add(param); } } if (selectorOptions.containsKey("subnodetypes")) { String param = selectorOptions.get("subnodetypes"); if (StringUtils.isEmpty(param)) { param = "jmix:editorialContent"; } String includedTypes = StringUtils.substringBefore(param, ";"); Set<String> excludedTypes = new HashSet<String>(); String exclusion = StringUtils.substringAfter(param, ";"); if (StringUtils.isNotBlank(exclusion)) { excludedTypes.addAll(CollectionUtils.collect( Arrays.asList(Patterns.COMMA.split(StringUtils.substringAfter(param, ";"))), new Transformer() { public Object transform(Object input) { return ((String) input).trim(); } })); } for (String nodeTypeName : Patterns.COMMA.split(includedTypes)) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug( filename + " found choicelist subnodetype included type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } for (String nodeTypeName : excludedTypes) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug( filename + " found choicelist subnodetype excluded type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } } if (selectorOptions.containsKey("componenttypes")) { String param = selectorOptions.get("componenttypes"); Set<String> DEF_INCLUDES = new TreeSet<String>(Arrays.asList("jmix:editorialContent")); Set<String> includeTypes = DEF_INCLUDES; Set<String> excludeTypes = new TreeSet<String>(); if (StringUtils.isNotEmpty(param)) { includeTypes = getNodeTypes(StringUtils.substringBefore(param, ";")); excludeTypes = getNodeTypes(StringUtils.substringAfter(param, ";")); } for (String nodeTypeName : includeTypes) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug(filename + " found choicelist component type included type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } for (String nodeTypeName : excludeTypes) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug(filename + " found choicelist component type included type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } } } } } // remove all content type references that are defined in this file to keep only exist definitions contentTypeReferences.removeAll(contentTypeDefinitions); }
From source file:org.jannocessor.collection.impl.PowerArrayList.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//www. j a v a2s .c o m public <T> PowerList<T> getTransformed(final Transformation<? super E, T> transformation) { PowerList copy = copy(); CollectionUtils.transform(copy, new Transformer() { public Object transform(Object input) { return transformation.transform((E) input); } }); return copy; }
From source file:org.jannocessor.collection.impl.PowerLinkedHashSet.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public <T> PowerSet<T> getTransformed(final Transformation<? super E, T> transformation) { PowerSet copy = copy();//from w w w . j av a 2 s.c om CollectionUtils.transform(copy, new Transformer() { public Object transform(Object input) { return transformation.transform((E) input); } }); return copy; }
From source file:org.jopendocument.dom.ODSingleXMLDocument.java
/** * Detach the children of elem whose names already exist in the body. * // w ww .j a v a2 s. c o m * @param elem the elem to be trimmed. * @throws org.jdom.JDOMException if an error occurs. */ protected final void detachDuplicate(org.jdom.Element elem) throws org.jdom.JDOMException { final String singularName = elem.getName().substring(0, elem.getName().length() - 1); final List thisNames = getXPath("./text:" + singularName + "s/text:" + singularName + "/@text:name") .selectNodes(getChild("body")); org.apache.commons.collections.CollectionUtils.transform(thisNames, new Transformer() { public Object transform(Object obj) { return ((org.jdom.Attribute) obj).getValue(); } }); final Iterator iter = elem.getChildren().iterator(); while (iter.hasNext()) { final org.jdom.Element decl = (org.jdom.Element) iter.next(); if (thisNames.contains(decl.getAttributeValue("name", getVersion().getTEXT()))) { // on retire les dj existant iter.remove(); } } }
From source file:org.jopendocument.dom.ODSingleXMLDocument.java
private List<String> mergeUnique(ODXMLDocument doc, String topElem, String elemToMerge, String attrFQName, ElementTransformer addTransf) throws org.jdom.JDOMException { List<String> added = new ArrayList<String>(); org.jdom.Element thisParent = this.getChild(topElem, true); org.jdom.xpath.XPath xp = this.getXPath("./" + elemToMerge + "/@" + attrFQName); // les styles de ce document List thisElemNames = xp.selectNodes(thisParent); // on transforme la liste d'attributs en liste de String org.apache.commons.collections.CollectionUtils.transform(thisElemNames, new Transformer() { public Object transform(Object obj) { return ((org.jdom.Attribute) obj).getValue(); }// w w w. j ava 2s.c o m }); // pour chaque style de l'autre document Iterator otherElemNames = xp.selectNodes(doc.getChild(topElem)).iterator(); while (otherElemNames.hasNext()) { org.jdom.Attribute attr = (org.jdom.Attribute) otherElemNames.next(); // on l'ajoute si non dj dedans if (!thisElemNames.contains(attr.getValue())) { thisParent.addContent(addTransf.transform((org.jdom.Element) attr.getParent().clone())); added.add(attr.getValue()); } } return added; }
From source file:org.kuali.kra.hierarchyrouting.UnitStop.java
public String toString() { return new ToStringBuilder(this).append("id", id).append("parent", parent == null ? null : parent.id) .append("children", StringUtils.join(CollectionUtils.collect(children, new Transformer() { public Object transform(Object o) { return ((UnitStop) o).id; }//from w ww .j a v a2s . c o m }), ',')).toString(); }