本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.JPackage类的典型用法代码示例。如果您正苦于以下问题:Java JPackage类的具体用法?Java JPackage怎么用?Java JPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JPackage类属于com.google.gwt.core.ext.typeinfo包,在下文中一共展示了JPackage类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findReflectedClasses
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
protected Set<JType> findReflectedClasses(final GeneratorContext context, final TypeOracle typeOracle,
final TreeLogger logger) throws UnableToCompleteException {
final Set<JType> types = new HashSet<JType>();
final Set<String> uediInterfaceNames = getUediInterfaceNames();
final Set<JClassType> uediInterfaces = new HashSet<JClassType>();
final String rootPackage = getRootPackage(context, logger);
for (final JPackage jPackage : typeOracle.getPackages()) {
for (final JClassType jType : jPackage.getTypes()) {
if (uediInterfaceNames.contains(jType.getQualifiedSourceName())) {
uediInterfaces.add(jType);
} else if (jType.isClass() != null && jType.isInterface() == null && !jType.isClass().isAbstract()
&& jType.getQualifiedSourceName().startsWith(rootPackage)) {
types.add(jType);
}
}
}
if (uediInterfaces.size() < uediInterfaceNames.size()) {
logger.log(Type.ERROR, "UEDIT: Unable to find UEDI interfaces in classpath. Aborting.");
throw new UnableToCompleteException();
}
return filter(types, uediInterfaces);
}
开发者ID:czyzby,项目名称:uedi,代码行数:24,代码来源:ReflectionPoolGenerator.java
示例2: generateMock
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
/**
* Generates a mock class for {@code interfaceToMock}.
*/
String generateMock(JClassType typeToMock) throws UnableToCompleteException {
JPackage interfacePackage = typeToMock.getPackage();
String packageName = interfacePackage == null ? "" : interfacePackage.getName();
String newClassName = typeToMock.getName().replace(".", "_") + "Mock";
// GenericType<Integer> has to generate a different mock implementation than
// GenericType<String>, that's what we check and do here
if (typeToMock.isParameterized() != null) {
StringBuilder typeList = new StringBuilder();
for (JClassType genericArg : typeToMock.isParameterized().getTypeArgs()) {
typeList.append(genericArg.getParameterizedQualifiedSourceName());
}
newClassName += Integer.toHexString(typeList.toString().hashCode());
}
String fullNewClassName = packageName + "." + newClassName;
PrintWriter printWriter = this.context.tryCreate(this.logger, packageName, newClassName);
if (printWriter == null) {
// We generated this before.
return fullNewClassName;
}
ClassSourceFileComposerFactory composer =
new ClassSourceFileComposerFactory(packageName, newClassName);
composer.addImport(MocksControlBase.class.getCanonicalName());
composer.addImport(Method.class.getCanonicalName());
composer.addImport(Call.class.getCanonicalName());
composer.addImport(UndeclaredThrowableException.class.getCanonicalName());
if (typeToMock.isInterface() != null) {
composer.addImplementedInterface(typeToMock.getParameterizedQualifiedSourceName());
} else {
composer.setSuperclass(typeToMock.getParameterizedQualifiedSourceName());
}
SourceWriter sourceWriter = composer.createSourceWriter(this.context, printWriter);
sourceWriter.println();
JMethod[] overridableMethods = typeToMock.getOverridableMethods();
List<JMethod> methodsToMock = new ArrayList<JMethod>();
Set<String> needsDefaultImplementation = new HashSet<String>();
for (JMethod method : overridableMethods) {
if (isSpecialMethodOfObject(method)) {
needsDefaultImplementation.add(method.getName());
} else if (method.getParameterTypes().length == 0 && method.getName().equals("getClass")) {
// ignore, Bug 5026788 in GWT
} else {
methodsToMock.add(method);
}
}
printFields(sourceWriter, methodsToMock);
printConstructors(sourceWriter, newClassName, typeToMock.getConstructors());
printMockMethods(sourceWriter, methodsToMock, newClassName);
printDefaultMethods(sourceWriter, typeToMock, needsDefaultImplementation);
sourceWriter.commit(this.logger);
return fullNewClassName;
}
开发者ID:google,项目名称:easy-gwt-mock,代码行数:66,代码来源:MocksGenerator.java
示例3: findReflectedClasses
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
private Set<JType> findReflectedClasses(final GeneratorContext context, final TypeOracle typeOracle,
final TreeLogger logger) throws UnableToCompleteException {
final Set<JType> types = new HashSet<JType>();
final JPackage[] packages = typeOracle.getPackages();
// gather all types from wanted packages
for (final JPackage jPackage : packages) {
for (final JClassType jType : jPackage.getTypes()) {
gatherTypes(jType.getErasedType(), types, context, logger);
}
}
// gather all types from explicitely requested packages
try {
final ConfigurationProperty reflectionProperties = context.getPropertyOracle()
.getConfigurationProperty("gdx.reflect.include");
for (final String property : reflectionProperties.getValues()) {
final JClassType type = typeOracle.findType(property);
if (type != null) {
gatherTypes(type.getErasedType(), types, context, logger);
}
}
} catch (final BadPropertyValueException exception) {
logger.log(Type.ERROR, "Unknown property: " + "gdx.reflect.include", exception);
throw new UnableToCompleteException();
}
gatherTypes(typeOracle.findType("java.util.List").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.util.ArrayList").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.util.HashMap").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.util.Map").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.String").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Boolean").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Byte").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Long").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Character").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Short").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Integer").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Float").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.CharSequence").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Double").getErasedType(), types, context, logger);
gatherTypes(typeOracle.findType("java.lang.Object").getErasedType(), types, context, logger);
return types;
}
开发者ID:czyzby,项目名称:gdx-lml,代码行数:46,代码来源:ReflectionPoolGenerator.java
示例4: getPackage
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
protected final String getPackage() {
final JPackage serviceIntfPkg = this.validatorType.getPackage();
return serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:5,代码来源:AbstractCreator.java
示例5: getSourceWriter
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx, JClassType intfType) {
JPackage serviceIntfPkg = intfType.getPackage();
String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
PrintWriter printWriter = ctx.tryCreate(logger, packageName, getTypeSimpleName());
if (printWriter == null) {
return null;
}
ClassSourceFileComposerFactory composerFactory =
new ClassSourceFileComposerFactory(packageName, getTypeSimpleName());
String[] imports = new String[] {
// java
ArrayList.class.getCanonicalName(),
Collection.class.getCanonicalName(),
HashSet.class.getCanonicalName(),
Iterator.class.getCanonicalName(),
LinkedHashSet.class.getCanonicalName(),
LinkedList.class.getCanonicalName(),
List.class.getCanonicalName(),
Set.class.getCanonicalName(),
TreeSet.class.getCanonicalName(),
// com.github.nmorel.gwtjackson
ObjectMapper.class.getCanonicalName(),
ObjectReader.class.getCanonicalName(),
ObjectWriter.class.getCanonicalName(),
// com.google.gwt
GWT.class.getCanonicalName(),
// org.turbogwt
Overlays.class.getCanonicalName(),
DeserializationContext.class.getCanonicalName(),
Deserializer.class.getCanonicalName(),
JsonRecordReader.class.getCanonicalName(),
JsonObjectSerdes.class.getCanonicalName(),
JsonRecordWriter.class.getCanonicalName(),
Serdes.class.getCanonicalName(),
SerializationContext.class.getCanonicalName(),
Serializer.class.getCanonicalName()
};
for (String imp : imports) {
composerFactory.addImport(imp);
}
composerFactory.addImplementedInterface(intfType.getErasedType().getQualifiedSourceName());
return composerFactory.createSourceWriter(ctx, printWriter);
}
开发者ID:growbit,项目名称:turbogwt-http,代码行数:49,代码来源:JsonSerdesGenerator.java
示例6: getSourceWriter
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx, JClassType intfType) {
JPackage serviceIntfPkg = intfType.getPackage();
String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
PrintWriter printWriter = ctx.tryCreate(logger, packageName, getTypeSimpleName());
if (printWriter == null) {
return null;
}
ClassSourceFileComposerFactory composerFactory =
new ClassSourceFileComposerFactory(packageName, getTypeSimpleName());
String[] imports = new String[]{
// java.util
ArrayList.class.getCanonicalName(),
Collection.class.getCanonicalName(),
List.class.getCanonicalName(),
Iterator.class.getCanonicalName(),
Set.class.getCanonicalName(),
// com.google.gwt.core.client
GWT.class.getCanonicalName(),
// com.google.web.bindery.autobean.shared
AutoBean.class.getCanonicalName(),
AutoBeanCodex.class.getCanonicalName(),
AutoBeanFactory.class.getCanonicalName(),
AutoBeanUtils.class.getCanonicalName(),
// io.reinert.requestor.serialization
DeserializationContext.class.getCanonicalName(),
Deserializer.class.getCanonicalName(),
HasImpl.class.getCanonicalName(),
Serdes.class.getCanonicalName(),
Serializer.class.getCanonicalName(),
SerializationContext.class.getCanonicalName(),
UnableToDeserializeException.class.getName(),
UnableToSerializeException.class.getName(),
// io.reinert.requestor.serialization.json
JsonObjectSerdes.class.getCanonicalName(),
JsonRecordReader.class.getCanonicalName(),
JsonRecordWriter.class.getCanonicalName(),
};
for (String imp : imports) {
composerFactory.addImport(imp);
}
composerFactory.addImplementedInterface(intfType.getErasedType().getQualifiedSourceName());
return composerFactory.createSourceWriter(ctx, printWriter);
}
开发者ID:reinert,项目名称:requestor,代码行数:49,代码来源:JsonAutoBeanGenerator.java
示例7: getSourceWriter
import com.google.gwt.core.ext.typeinfo.JPackage; //导入依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx, JClassType intfType) {
JPackage serviceIntfPkg = intfType.getPackage();
String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
PrintWriter printWriter = ctx.tryCreate(logger, packageName, getTypeSimpleName());
if (printWriter == null) {
return null;
}
ClassSourceFileComposerFactory composerFactory =
new ClassSourceFileComposerFactory(packageName, getTypeSimpleName());
String[] imports = new String[]{
// java
ArrayList.class.getCanonicalName(),
Collection.class.getCanonicalName(),
HashSet.class.getCanonicalName(),
Iterator.class.getCanonicalName(),
LinkedHashSet.class.getCanonicalName(),
LinkedList.class.getCanonicalName(),
List.class.getCanonicalName(),
Set.class.getCanonicalName(),
TreeSet.class.getCanonicalName(),
// com.github.nmorel.gwtjackson
ObjectMapper.class.getCanonicalName(),
ObjectReader.class.getCanonicalName(),
ObjectWriter.class.getCanonicalName(),
// com.google.gwt
GWT.class.getCanonicalName(),
// io.reinert.requestor
DeserializationContext.class.getCanonicalName(),
Deserializer.class.getCanonicalName(),
JsonObjectSerdes.class.getCanonicalName(),
JsonRecordReader.class.getCanonicalName(),
JsonRecordWriter.class.getCanonicalName(),
UnableToDeserializeException.class.getName(),
UnableToSerializeException.class.getName(),
Serdes.class.getCanonicalName(),
Serializer.class.getCanonicalName(),
SerializationContext.class.getCanonicalName()
};
for (String imp : imports) {
composerFactory.addImport(imp);
}
composerFactory.addImplementedInterface(intfType.getErasedType().getQualifiedSourceName());
return composerFactory.createSourceWriter(ctx, printWriter);
}
开发者ID:reinert,项目名称:requestor,代码行数:50,代码来源:JsonGwtJacksonGenerator.java
注:本文中的com.google.gwt.core.ext.typeinfo.JPackage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论