當前位置: 首頁>>代碼示例>>Java>>正文


Java Transformer.transform方法代碼示例

本文整理匯總了Java中org.apache.commons.collections.Transformer.transform方法的典型用法代碼示例。如果您正苦於以下問題:Java Transformer.transform方法的具體用法?Java Transformer.transform怎麽用?Java Transformer.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.collections.Transformer的用法示例。


在下文中一共展示了Transformer.transform方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAttachements

import org.apache.commons.collections.Transformer; //導入方法依賴的package包/類
public static Map<String,Object> getAttachements(Object obj, Transformer transformer) {
    Map<String,Object> result = new LinkedHashMap<String, Object>();
    Object key = getAttachementKey(obj);
    ApiRequest request = ApiContext.getContext().getApiRequest();
    @SuppressWarnings("unchecked")
    Map<String,Map<Object,Object>> attachments = (Map<String, Map<Object,Object>>) request.getAttribute(key);

    if ( attachments == null ) {
        return result;
    }

    for ( Map.Entry<String, Map<Object,Object>> entry : attachments.entrySet() ) {
        String keyName = entry.getKey();
        List<Object> objects = new ArrayList<Object>();
        for ( Object attachment : entry.getValue().values() ) {
            attachment = transformer.transform(attachment);
            if ( attachment != null ) {
                objects.add(attachment);
            }
        }

        if ( keyName.startsWith(SINGLE_ATTACHMENT_PREFIX) ) {
            Object attachedObj = objects.size() > 0 ? objects.get(0) : null;
            result.put(keyName.substring(SINGLE_ATTACHMENT_PREFIX.length()), attachedObj);
        } else {
            result.put(keyName, objects);
        }
    }

    return result;
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:32,代碼來源:ApiUtils.java

示例2: initBlankCache

import org.apache.commons.collections.Transformer; //導入方法依賴的package包/類
/** This is a blank initialization method. It creates the structure of a new
 * Alias cache without filling it with content. This code is separated from 
 * the data filling from the semantic repository - for class extension
 * convenience.<br>
 * @param ignoreAliases - a String list of aliases to be ignored.
 */
protected void initBlankCache(Collection<String> ignoreAliases) {
  aliasRegister = new HashRegister();
  aliasPrefixes = new TIntHashSet();
  aliasInstRegister = new HashRegister();
  instNS = new ArrayList<String>();
  classCache = new ArrayList<String>();

  // Create a TextTransformer instance for Alias text normalization
  Transformer tt = new AliasTextTransformer(
          caseSensitivity.equals(Options.INSENSITIVE));
  ParsingFrame.frameTT = tt;
  aliasToIgnore = new HashRegister();
  if (ignoreAliases != null) {
    for (String alias : ignoreAliases) {
      // Apply same text normalization to the aliases to be ignored 
      alias = (String)tt.transform(alias);
      aliasToIgnore.add(alias.hashCode(), alias);
      if (caseSensitivity.equals(Options.ALL_UPPER)) {
        alias = alias.toUpperCase();
        aliasToIgnore.add(alias.hashCode(), alias);
      }
    }
  }
  log.info(
          "Aliases in IGNORE list:" + aliasToIgnore.getElementsCount());

}
 
開發者ID:Network-of-BioThings,項目名稱:GettinCRAFTy,代碼行數:34,代碼來源:AliasCacheImpl.java

示例3: groupByToSet

import org.apache.commons.collections.Transformer; //導入方法依賴的package包/類
public static <K, V> Map<K, Set<V>> groupByToSet(Collection<V> items, Transformer keyExtractor) {
    Map<K, Set<V>> map = new HashMap<K, Set<V>>();
    for (V item : items) {
        K key = (K) keyExtractor.transform(item);
        Set<V> set = map.get(key);
        if (set == null) {
            set = new HashSet<V>();
            map.put(key, set);
        }
        set.add(item);
    }
    return map;
}
 
開發者ID:Semantive,項目名稱:hiqual,代碼行數:14,代碼來源:SemantiveCollectionUtils.java

示例4: applyTransformations

import org.apache.commons.collections.Transformer; //導入方法依賴的package包/類
private static void applyTransformations(Set<SecurityPolicy> policies, Object entity, PropertyAccessor propAccessor)
        throws IllegalAccessException, InvocationTargetException {
    Transformer transformer = getPropertyTransformer(policies, propAccessor);
    if (transformer != null) {
        Object originalVal = propAccessor.get(entity);
        Object transformedVal = transformer.transform(originalVal);
        propAccessor.set(entity, transformedVal);
    }
    Closure mutator = getPropertyMutator(policies, propAccessor);
    if (mutator != null) {
        mutator.execute(propAccessor.get(entity));
    }
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:14,代碼來源:SecurityPolicy.java

示例5: convertType

import org.apache.commons.collections.Transformer; //導入方法依賴的package包/類
/**
 * Converts the given value to the given type.  First, reflection is
 * is used to find a public constructor declared by the given class
 * that takes one argument, which must be the precise type of the
 * given value.  If such a constructor is found, a new object is
 * created by passing the given value to that constructor, and the
 * newly constructed object is returned.<P>
 *
 * If no such constructor exists, and the given type is a primitive
 * type, then the given value is converted to a string using its
 * {@link Object#toString() toString()} method, and that string is
 * parsed into the correct primitive type using, for instance,
 * {@link Integer#valueOf(String)} to convert the string into an
 * <code>int</code>.<P>
 *
 * If no special constructor exists and the given type is not a
 * primitive type, this method returns the original value.
 *
 * @param newType  the type to convert the value to
 * @param value  the value to convert
 * @return the converted value
 * @throws NumberFormatException if newType is a primitive type, and
 *  the string representation of the given value cannot be converted
 *  to that type
 * @throws InstantiationException  if the constructor found with
 *  reflection raises it
 * @throws InvocationTargetException  if the constructor found with
 *  reflection raises it
 * @throws IllegalAccessException  never
 * @throws IllegalArgumentException  never
 */
protected Object convertType( final Class<?> newType, final Object value )
    throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {

    // try call constructor
    final Class<?>[] types = { value.getClass() };
    try {
        final Constructor<?> constructor = newType.getConstructor( types );
        final Object[] arguments = { value };
        return constructor.newInstance( arguments );
    }
    catch ( final NoSuchMethodException e ) {
        // try using the transformers
        final Transformer transformer = getTypeTransformer( newType );
        if ( transformer != null ) {
            return transformer.transform( value );
        }
        return value;
    }
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:51,代碼來源:BeanMap.java

示例6: getParent

import org.apache.commons.collections.Transformer; //導入方法依賴的package包/類
@Override
public Object getParent() {
    final Transformer transformer = new ElementTransformer();
    return transformer.transform(element.getParentElement());
}
 
開發者ID:apache,項目名稱:karaf-eik,代碼行數:6,代碼來源:Bundle.java


注:本文中的org.apache.commons.collections.Transformer.transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。