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


Java Factory类代码示例

本文整理汇总了Java中org.aikodi.chameleon.core.factory.Factory的典型用法代码示例。如果您正苦于以下问题:Java Factory类的具体用法?Java Factory怎么用?Java Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Factory类属于org.aikodi.chameleon.core.factory包,在下文中一共展示了Factory类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: erasure

import org.aikodi.chameleon.core.factory.Factory; //导入依赖的package包/类
@Override
public Type erasure() {
	Element el = farthestOrigin();
	if(el != this) {
		return ((JavaType)el).erasure();
	}
	// I am not sure whether this is correct. The memberInheritanceRelations are not erased in RawType.
	Type outmostType = lexical().farthestAncestor(Type.class);
	if(outmostType == null) {
		outmostType = this;
	}
	RawType outer;
	if(outmostType instanceof RawType) {
		outer = (RawType) outmostType;
	} else {
		outer = new RawType(outmostType);
	}
	RawType current = outer;
	List<Type> outerTypes = ancestors(Type.class);
	outerTypes.add(0, this);

	int size = outerTypes.size();
	Factory expressionFactory = language(ObjectOrientedLanguage.class).plugin(Factory.class);
	for(int i = size - 2; i>=0;i--) {
		NameReference<RawType> simpleRef = expressionFactory.createNameReference(outerTypes.get(i).name(), RawType.class);
		simpleRef.setUniParent(current);
		try {
			current = simpleRef.getElement();
		} catch (LookupException e) {
			e.printStackTrace();
			throw new ChameleonProgrammerException("An inner type of a newly created outer raw type cannot be found",e);
		}
	}
	return current;	
}
 
开发者ID:markovandooren,项目名称:jlo,代码行数:36,代码来源:SubobjectType.java

示例2: create

import org.aikodi.chameleon.core.factory.Factory; //导入依赖的package包/类
/**
	 * Create a JLo language object with the following plugins attached:
	 * <ul>
	 *  <li>Syntax: JLoSyntax</li>
	 *  <li>ModelFactory: JLoModelFactory</li>
    *  <li>Factory: JLoFactory</li>
	 *  <li>ObjectOrientedFactory: JLoFactory</li>
	 *  <li>ProjectConfigurator: JLoConfigLoader</li>
	 * </ul>
	 * @return
	 */
	public JLo create() {
		JLo result = new JLo();
		result.setPlugin(ModelFactory.class, new JLoModelFactory());
//    result.setPlugin(ModelFactory.class, new OldJLoModelFactory());
		result.setPlugin(Syntax.class, new JLoSyntax());
		JLoFactory factory = new JLoFactory();
      result.setPlugin(Factory.class, factory);
		result.setPlugin(ObjectOrientedFactory.class, factory);
		result.setPlugin(ExpressionFactory.class, new JavaExpressionFactory());
		result.setPlugin(ProjectConfigurator.class, new JLoProjectConfigurator(Java7LanguageFactory.javaBaseJar()));
		return result;
	}
 
开发者ID:markovandooren,项目名称:jlo,代码行数:24,代码来源:JLoLanguageFactory.java

示例3: erasure

import org.aikodi.chameleon.core.factory.Factory; //导入依赖的package包/类
@Override
	public Type erasure() {
		// FIXME this code seems to have been duplicated a number of times.
		Java7 language = language(Java7.class);
		Type result = _rawTypeCache;
		if (result == null) {
			if (is(language.INSTANCE) == Ternary.TRUE) {
				Type outmostType = lexical().farthestAncestor(Type.class);
				Type outer;
				if (outmostType == null) {
//					outmostType = this;
//					if(nbTypeParameters(TypeParameter.class) > 0) {
					  outer = new RawType(this);
//					} else {
//						outer = this;
//					}
				} else {
					if (outmostType instanceof RawType) {
						outer = (RawType) outmostType;
					} else {
						outer = ((JavaType)outmostType).erasure();
					}
				}
				Type current = outer;
				List<Type> outerTypes = ancestors(Type.class);
				outerTypes.add(0, this);

				int size = outerTypes.size();
				Factory expressionFactory = language.plugin(Factory.class);
				for (int i = size - 2; i >= 0; i--) {
					NameReference<Type> simpleRef = expressionFactory.createNameReference(outerTypes.get(i).name(),
							(Class) Type.class);
					simpleRef.setUniParent(current);
					try {
						current = simpleRef.getElement();
					} catch (LookupException e) {
						e.printStackTrace();
						throw new ChameleonProgrammerException("An inner type of a newly created outer raw type cannot be found", e);
					}
				}
				result = current;
			} else {
				// static
				if(nbTypeParameters(TypeParameter.class) > 0) {
				  result = new RawType(this);
				} else {
					result = this;
				}
			}
			_rawTypeCache = result;
		}
		return result;
	}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:54,代码来源:RegularJavaType.java

示例4: factory

import org.aikodi.chameleon.core.factory.Factory; //导入依赖的package包/类
protected Factory factory() {
  return jlo().plugin(Factory.class);
}
 
开发者ID:markovandooren,项目名称:jlo,代码行数:4,代码来源:JLoConvertor.java

示例5: create

import org.aikodi.chameleon.core.factory.Factory; //导入依赖的package包/类
/**
  * {@inheritDoc}
  * 
  * <p>The resulting language object has the following plugins:</p>
  * <ol>
  *   <li>{@link ModelFactory} : {@link JavaModelFactory}</li>
  *   <li>{@link Syntax} : {@link Java7Syntax}</li>
  *   <li>{@link Factory} : {@link Java7Factory}</li>
  *   <li>{@link ObjectOrientedFactory} : {@link Java7Factory}</li>
  *   <li>{@link ExpressionFactory} : {@link JavaExpressionFactory}</li>
  *   <li>{@link ProjectConfigurator} : {@link JavaProjectConfigurator}</li>
  * </ol>
  */
public Java7 create() throws ConfigException {
	Java7 result = new Java7();
	result.setPlugin(ModelFactory.class, new JavaModelFactory());
	result.setPlugin(Syntax.class, new Java7Syntax());
	// FIXME: Stupid and inefficient
	result.setPlugin(Factory.class, new Java7Factory());
	result.setPlugin(ObjectOrientedFactory.class, new Java7Factory());
	result.setPlugin(ExpressionFactory.class, new JavaExpressionFactory());
	JarFile jarName = javaBaseJar();
	result.setPlugin(ProjectConfigurator.class, new JavaProjectConfigurator(jarName));
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:26,代码来源:Java7LanguageFactory.java


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