本文整理了Java中com.sun.codemodel.JPackage._getClass()
方法的一些代码示例,展示了JPackage._getClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPackage._getClass()
方法的具体详情如下:
包路径:com.sun.codemodel.JPackage
类名称:JPackage
方法名:_getClass
[英]Gets a reference to the already created JDefinedClass.
[中]获取对已创建的JDefinedClass的引用。
代码示例来源:origin: joelittlejohn/jsonschema2pojo
private static JDefinedClass definedClassOrNullFromType(JType type)
{
if (type == null || type.isPrimitive())
{
return null;
}
JClass fieldClass = type.boxify();
JPackage jPackage = fieldClass._package();
return jPackage._getClass(fieldClass.name());
}
代码示例来源:origin: org.jvnet.jaxbvalidation/jaxbvalidation-core
public static JDefinedClass getObjectValidatorFactoryClass(final JPackage thePackage) {
return thePackage._getClass("ObjectValidatorFactory");
}
代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools
public static JDefinedClass _getClass(JPackage _package, String name) {
final int idx = name.lastIndexOf('$');
if (idx < 0) {
return _package._getClass(name);
} else {
final String parentClassName = name.substring(0, idx);
final JDefinedClass parentClass = _package
._getClass(parentClassName);
if (parentClass == null) {
return null;
} else {
return _getClass(parentClass, name.substring(idx + 1));
}
}
}
代码示例来源:origin: com.unquietcode.tools.jcodemodel/codemodel
/**
* Gets a reference to the already created generated class.
*
* @return null
* If the class is not yet created.
* @see JPackage#_getClass(String)
*/
public JDefinedClass _getClass(String fullyQualifiedName) {
int idx = fullyQualifiedName.lastIndexOf('.');
if( idx<0 ) return rootPackage()._getClass(fullyQualifiedName);
else
return _package(fullyQualifiedName.substring(0,idx))
._getClass( fullyQualifiedName.substring(idx+1) );
}
代码示例来源:origin: javaee/jaxb-v2
/**
* Gets a reference to the already created generated class.
*
* @return null
* If the class is not yet created.
* @see JPackage#_getClass(String)
*/
public JDefinedClass _getClass(String fullyQualifiedName) {
int idx = fullyQualifiedName.lastIndexOf('.');
if( idx<0 ) return rootPackage()._getClass(fullyQualifiedName);
else
return _package(fullyQualifiedName.substring(0,idx))
._getClass( fullyQualifiedName.substring(idx+1) );
}
代码示例来源:origin: org.glassfish.metro/webservices-tools
/**
* Gets a reference to the already created generated class.
*
* @return null
* If the class is not yet created.
* @see JPackage#_getClass(String)
*/
public JDefinedClass _getClass(String fullyQualifiedName) {
int idx = fullyQualifiedName.lastIndexOf('.');
if( idx<0 ) return rootPackage()._getClass(fullyQualifiedName);
else
return _package(fullyQualifiedName.substring(0,idx))
._getClass( fullyQualifiedName.substring(idx+1) );
}
代码示例来源:origin: sun-jaxb/jaxb-xjc
/**
* Gets a reference to the already created generated class.
*
* @return null
* If the class is not yet created.
* @see JPackage#_getClass(String)
*/
public JDefinedClass _getClass(String fullyQualifiedName) {
int idx = fullyQualifiedName.lastIndexOf('.');
if( idx<0 ) return rootPackage()._getClass(fullyQualifiedName);
else
return _package(fullyQualifiedName.substring(0,idx))
._getClass( fullyQualifiedName.substring(idx+1) );
}
代码示例来源:origin: com.sun.codemodel/codemodel
/**
* Gets a reference to the already created generated class.
*
* @return null
* If the class is not yet created.
* @see JPackage#_getClass(String)
*/
public JDefinedClass _getClass(String fullyQualifiedName) {
int idx = fullyQualifiedName.lastIndexOf('.');
if( idx<0 ) return rootPackage()._getClass(fullyQualifiedName);
else
return _package(fullyQualifiedName.substring(0,idx))
._getClass( fullyQualifiedName.substring(idx+1) );
}
代码示例来源:origin: phoenixnap/springmvc-raml-plugin
@Override
public JDefinedClass apply(ApiResourceMetadata controllerMetadata, JPackage generatableType) {
String controllerClassName = controllerMetadata.getResourceName().concat("Client");
JDefinedClass definedClass;
try {
definedClass = generatableType._interface(controllerClassName);
} catch (JClassAlreadyExistsException e1) {
definedClass = generatableType._getClass(controllerClassName);
}
return definedClass;
}
代码示例来源:origin: phoenixnap/springmvc-raml-plugin
@Override
public JDefinedClass apply(ApiResourceMetadata controllerMetadata, JPackage generatableType) {
String resourceClassName = controllerMetadata.getName() + classNameSuffix;
JDefinedClass definedClass;
try {
definedClass = generatableType._class(resourceClassName);
} catch (JClassAlreadyExistsException e1) {
definedClass = generatableType._getClass(resourceClassName);
}
return definedClass;
}
代码示例来源:origin: phoenixnap/springmvc-raml-plugin
@Override
public JDefinedClass apply(ApiResourceMetadata controllerMetadata, JPackage generatableType) {
String controllerClassName = controllerMetadata.getName() + CONTROLLER_SUFFIX;
JDefinedClass definedClass;
try {
definedClass = generatableType._interface(controllerClassName);
} catch (JClassAlreadyExistsException e1) {
definedClass = generatableType._getClass(controllerClassName);
}
return definedClass;
}
代码示例来源:origin: phoenixnap/springmvc-raml-plugin
@Override
public JDefinedClass apply(ApiResourceMetadata controllerMetadata, JPackage generatableType) {
String clientClassName = controllerMetadata.getName() + CLIENT_SUFFIX;
JDefinedClass definedClass;
try {
definedClass = generatableType._interface(clientClassName);
} catch (JClassAlreadyExistsException e1) {
definedClass = generatableType._getClass(clientClassName);
}
return definedClass;
}
代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools
public static JDefinedClass _getClass(JCodeModel codeModel,
String fullyQualifiedName) {
final int idx = fullyQualifiedName.lastIndexOf('.');
if (idx < 0) {
return codeModel.rootPackage()._getClass(fullyQualifiedName);
} else {
final String packageName = fullyQualifiedName.substring(0, idx);
for (Iterator<JPackage> iterator = codeModel.packages(); iterator
.hasNext();) {
final JPackage _package = iterator.next();
if (packageName.equals(_package.name())) {
return _getClass(_package,
fullyQualifiedName.substring(idx + 1));
}
}
return null;
}
}
代码示例来源:origin: com.github.jaxb-xew-plugin/jaxb-xew-plugin
/**
* For the given class locate and add Object Factory classes to the map.
*
* @return {@code true} if value class generation is enabled
*/
public boolean addObjectFactoryForClass(JDefinedClass clazz) {
JDefinedClass valueObjectFactoryClass = clazz._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClasses.containsKey(valueObjectFactoryClass.fullName())) {
return false;
}
objectFactoryClasses.put(valueObjectFactoryClass.fullName(), valueObjectFactoryClass);
JDefinedClass objectFactoryClass = null;
// If class has a non-hidden interface, then there is object factory in another package.
for (Iterator<JClass> iter = clazz._implements(); iter.hasNext();) {
JClass interfaceClass = iter.next();
if (!isHiddenClass(interfaceClass)) {
objectFactoryClass = interfaceClass._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClass != null) {
objectFactoryClasses.put(objectFactoryClass.fullName(), objectFactoryClass);
}
}
}
return objectFactoryClass != null;
}
代码示例来源:origin: dmak/jaxb-xew-plugin
/**
* For the given class locate and add Object Factory classes to the map.
*
* @return {@code true} if value class generation is enabled
*/
public boolean addObjectFactoryForClass(JDefinedClass clazz) {
JDefinedClass valueObjectFactoryClass = clazz._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClasses.containsKey(valueObjectFactoryClass.fullName())) {
return false;
}
objectFactoryClasses.put(valueObjectFactoryClass.fullName(), valueObjectFactoryClass);
JDefinedClass objectFactoryClass = null;
// If class has a non-hidden interface, then there is object factory in another package.
for (Iterator<JClass> iter = clazz._implements(); iter.hasNext();) {
JClass interfaceClass = iter.next();
if (!isHiddenClass(interfaceClass)) {
objectFactoryClass = interfaceClass._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClass != null) {
objectFactoryClasses.put(objectFactoryClass.fullName(), objectFactoryClass);
}
}
}
return objectFactoryClass != null;
}
代码示例来源:origin: org.metatype.sxc/sxc-jaxb
public JFieldRef getAdapter(Class adapterType) {
String adapterId = adapterType.getName();
JFieldRef ref = adapters.get(adapterId);
if (ref == null) {
final String fieldName = decapitalize(adapterType.getSimpleName()) + "Adapter";
final JPackage jPackage = jaxbObjectClass.getPackage();
final JDefinedClass definedClass;
if (jPackage._getClass("Adapters") != null) {
definedClass = jPackage._getClass("Adapters");
if (!definedClass.fields().containsKey(fieldName)) {
JClass jClass = builderContext.toJClass(adapterType);
definedClass.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, jClass, fieldName, JExpr._new(jClass));
}
} else {
try {
definedClass = jPackage._class("Adapters");
JClass jClass = builderContext.toJClass(adapterType);
definedClass.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, jClass, fieldName, JExpr._new(jClass));
} catch (JClassAlreadyExistsException e) {
throw new IllegalStateException(e);
}
}
ref = definedClass.staticRef(fieldName);
adapters.put(adapterId, ref);
}
return ref;
}
代码示例来源:origin: org.jsonschema2pojo/jsonschema2pojo-core
private static JDefinedClass definedClassOrNullFromType(JType type)
{
if (type == null || type.isPrimitive())
{
return null;
}
JClass fieldClass = type.boxify();
JPackage jPackage = fieldClass._package();
return jPackage._getClass(fieldClass.name());
}
代码示例来源:origin: uk.org.retep.tools/jaxb
private JDefinedClass resolveClass( final Context ctx )
throws SAXException
{
// The output class
JDefinedClass cd = ctx.co.ref;
if( StringUtils.isStringNotEmpty( ctx.className ) )
{
cd = ctx.co.ref._package()._getClass( ctx.className );
if( cd == null )
{
try
{
cd = ctx.co.ref._package()._class( ctx.className );
}
catch( JClassAlreadyExistsException ex )
{
throw new SAXException( ex.getMessage(), ex );
}
}
if( cd == null )
{
throw new SAXException( "Unable to locate " + ctx.className );
}
}
return cd;
}
代码示例来源:origin: com.github.jaxb-xew-plugin/jaxb-xew-plugin
/**
* If candidate class contains the inner class which is collection parametrisation (type), then this inner class has
* to be moved to top class. For example from<br>
* {@code TypeClass (is a collection type) -> ContainerClass (marked for removal) -> ElementClass}<br>
* we need to get<br>
* {@code TypeClass -> ElementClass}.<br>
* Also this move should be reflected on factory method names.
*/
private boolean moveInnerClassToParent(Outline outline, Candidate candidate) {
// Skip basic parametrisations like "List<String>":
if (candidate.getFieldParametrisationClass() == null) {
return false;
}
JDefinedClass fieldParametrisationImpl = candidate.getFieldParametrisationImpl();
if (candidate.getClazz() != fieldParametrisationImpl.parentContainer()) {
// Field parametrisation class is not inner class of the candidate:
return false;
}
JDefinedClass fieldParametrisationClass = candidate.getFieldParametrisationClass();
String oldFactoryMethodName = fieldParametrisationClass.outer().name() + fieldParametrisationClass.name();
moveClassLevelUp(outline, fieldParametrisationImpl);
renameFactoryMethod(fieldParametrisationImpl._package()._getClass(FACTORY_CLASS_NAME), oldFactoryMethodName,
fieldParametrisationClass.name());
if (candidate.isValueObjectDisabled()) {
moveClassLevelUp(outline, fieldParametrisationClass);
renameFactoryMethod(fieldParametrisationClass._package()._getClass(FACTORY_CLASS_NAME),
oldFactoryMethodName, fieldParametrisationClass.name());
}
return true;
}
代码示例来源:origin: dmak/jaxb-xew-plugin
/**
* If candidate class contains the inner class which is collection parametrisation (type), then this inner class has
* to be moved to top class. For example from<br>
* {@code TypeClass (is a collection type) -> ContainerClass (marked for removal) -> ElementClass}<br>
* we need to get<br>
* {@code TypeClass -> ElementClass}.<br>
* Also this move should be reflected on factory method names.
*/
private boolean moveInnerClassToParent(Outline outline, Candidate candidate) {
// Skip basic parametrisations like "List<String>":
if (candidate.getFieldParametrisationClass() == null) {
return false;
}
JDefinedClass fieldParametrisationImpl = candidate.getFieldParametrisationImpl();
if (candidate.getClazz() != fieldParametrisationImpl.parentContainer()) {
// Field parametrisation class is not inner class of the candidate:
return false;
}
JDefinedClass fieldParametrisationClass = candidate.getFieldParametrisationClass();
String oldFactoryMethodName = fieldParametrisationClass.outer().name() + fieldParametrisationClass.name();
moveClassLevelUp(outline, fieldParametrisationImpl);
renameFactoryMethod(fieldParametrisationImpl._package()._getClass(FACTORY_CLASS_NAME), oldFactoryMethodName,
fieldParametrisationClass.name());
if (candidate.isValueObjectDisabled()) {
moveClassLevelUp(outline, fieldParametrisationClass);
renameFactoryMethod(fieldParametrisationClass._package()._getClass(FACTORY_CLASS_NAME),
oldFactoryMethodName, fieldParametrisationClass.name());
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!