本文整理汇总了Java中com.sun.codemodel.internal.JPackage类的典型用法代码示例。如果您正苦于以下问题:Java JPackage类的具体用法?Java JPackage怎么用?Java JPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JPackage类属于com.sun.codemodel.internal包,在下文中一共展示了JPackage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getUsedPackages
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
/**
* Returns all <i>used</i> JPackages.
*
* A JPackage is considered as "used" if a ClassItem or
* a InterfaceItem resides in that package.
*
* This value is dynamically calculated every time because
* one can freely remove ClassItem/InterfaceItem.
*
* @return
* Given the same input, the order of packages in the array
* is always the same regardless of the environment.
*/
public final JPackage[] getUsedPackages(Aspect aspect) {
Set<JPackage> s = new TreeSet<JPackage>();
for (CClassInfo bean : model.beans().values()) {
JClassContainer cont = getContainer(bean.parent(), aspect);
if (cont.isPackage()) {
s.add((JPackage) cont);
}
}
for (CElementInfo e : model.getElementMappings(null).values()) {
// at the first glance you might think we should be iterating all elements,
// not just global ones, but if you think about it, local ones live inside
// another class, so those packages are already enumerated when we were
// walking over CClassInfos.
s.add(e._package());
}
return s.toArray(new JPackage[s.size()]);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:BeanGenerator.java
示例2: generateStaticClass
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public JClass generateStaticClass(Class src, JPackage out) {
String shortName = getShortName(src.getName());
// some people didn't like our jars to contain files with .java extension,
// so when we build jars, we'' use ".java_". But when we run from the workspace,
// we want the original source code to be used, so we check both here.
// see bug 6211503.
URL res = src.getResource(shortName + ".java");
if (res == null) {
res = src.getResource(shortName + ".java_");
}
if (res == null) {
throw new InternalError("Unable to load source code of " + src.getName() + " as a resource");
}
JStaticJavaFile sjf = new JStaticJavaFile(out, shortName, res, null);
out.addResourceFile(sjf);
return sjf.getJClass();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:BeanGenerator.java
示例3: dump
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
private void dump() throws IOException {
// collect packages used in the class.
Set<JPackage> packages = new TreeSet<JPackage>(new Comparator<JPackage>() {
public int compare(JPackage lhs, JPackage rhs) {
return lhs.name().compareTo(rhs.name());
}
});
for( ClassOutline ci : classes )
packages.add(ci._package()._package());
for( JPackage pkg : packages )
dump( pkg );
out.flush();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SignatureWriter.java
示例4: openSource
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public Writer openSource(JPackage pkg, String fileName) throws IOException {
Writer w = super.openSource(pkg,fileName);
PrintWriter out = new PrintWriter(w);
// write prolog if this is a java source file
if( prolog != null ) {
out.println( "//" );
String s = prolog;
int idx;
while( (idx=s.indexOf('\n'))!=-1 ) {
out.println("// "+ s.substring(0,idx) );
s = s.substring(idx+1);
}
out.println("//");
out.println();
}
out.flush(); // we can't close the stream for that would close the undelying stream.
return w;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:PrologCodeWriter.java
示例5: report
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
/**
* Report progress to {@link XJCListener}.
* @param pkg The package of file being written. Value of {@code null} means that file has no package.
* @param fileName The file name being written. Value can't be {@code null}.
*/
private void report(final JPackage pkg, final String fileName) {
if (fileName == null) {
throw new IllegalArgumentException("File name is null");
}
final String pkgName;
final String fileNameOut;
if (pkg != null && (pkgName = pkg.name().replace('.', File.separatorChar)).length() > 0 ) {
final StringBuilder sb = new StringBuilder(fileName.length() + pkgName.length() + 1);
sb.append(pkgName);
sb.append(File.separatorChar);
sb.append(fileName);
fileNameOut = sb.toString();
} else {
fileNameOut = fileName;
}
if(progress.isCanceled())
throw new AbortException();
progress.generatedFile(fileNameOut, current++, totalFileCount);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ProgressCodeWriter.java
示例6: openSource
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
@Override
public Writer openSource(JPackage pkg, String fileName) throws IOException {
Writer w = super.openSource(pkg,fileName);
PrintWriter out = new PrintWriter(w);
// write prolog if this is a java source file
if( prolog != null ) {
out.println( "//" );
String s = prolog;
int idx;
while( (idx=s.indexOf('\n'))!=-1 ) {
out.println("// "+ s.substring(0,idx) );
s = s.substring(idx+1);
}
out.println("//");
out.println();
}
out.flush(); // we can't close the stream for that would close the undelying stream.
return w;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:PrologCodeWriter.java
示例7: openBinary
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
final String name = pkg != null && pkg.name().length() > 0
? pkg.name() + '.' + fileName : fileName;
out.println(
"-----------------------------------" + name +
"-----------------------------------");
return new FilterOutputStream(out) {
@Override
public void close() {
// don't let this stream close
}
};
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SingleStreamCodeWriter.java
示例8: getFile
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
protected File getFile(JPackage pkg, String fileName ) throws IOException {
File f = super.getFile(pkg, fileName);
options.addGeneratedFile(f);
// we can't really tell the file type, for we don't know
// what this file is used for. Fortunately,
// FILE_TYPE doesn't seem to be used, so it doesn't really
// matter what we set.
return f;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:WSCodeWriter.java
示例9: openSource
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public Writer openSource(JPackage pkg, String fileName) throws IOException {
String tmp = fileName.substring(0, fileName.length()-5);
if (pkg.name() != null && ! "".equals(pkg.name())) {
w = filer.createSourceFile(pkg.name() + "." + tmp).openWriter();
} else {
w = filer.createSourceFile(tmp).openWriter();
}
return w;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:FilerCodeWriter.java
示例10: getPackageContext
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public PackageOutlineImpl getPackageContext(JPackage p) {
PackageOutlineImpl r = packageContexts.get(p);
if (r == null) {
r = new PackageOutlineImpl(this, model, p);
packageContexts.put(p, r);
}
return r;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:BeanGenerator.java
示例11: addRuntime
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public final JClass addRuntime(Class clazz) {
JClass g = generatedRuntime.get(clazz);
if (g == null) {
// put code into a separate package to avoid name conflicts.
JPackage implPkg = getUsedPackages(Aspect.IMPLEMENTATION)[0].subPackage("runtime");
g = generateStaticClass(clazz, implPkg);
generatedRuntime.put(clazz, g);
}
return g;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:BeanGenerator.java
示例12: PackageOutlineImpl
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
protected PackageOutlineImpl( BeanGenerator outline, Model model, JPackage _pkg ) {
this._model = model;
this._package = _pkg;
switch(model.strategy) {
case BEAN_ONLY:
objectFactoryGenerator = new PublicObjectFactoryGenerator(outline,model,_pkg);
break;
case INTF_AND_IMPL:
objectFactoryGenerator = new DualObjectFactoryGenerator(outline,model,_pkg);
break;
default:
throw new IllegalStateException();
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:PackageOutlineImpl.java
示例13: DualObjectFactoryGenerator
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
DualObjectFactoryGenerator(BeanGenerator outline, Model model, JPackage targetPackage) {
this.publicOFG = new PublicObjectFactoryGenerator(outline,model,targetPackage);
this.privateOFG = new PrivateObjectFactoryGenerator(outline,model,targetPackage);
// put the marker so that we can detect missing jaxb.properties
publicOFG.getObjectFactory().field(JMod.PRIVATE|JMod.STATIC|JMod.FINAL,
Void.class, "_useJAXBProperties", JExpr._null());
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:DualObjectFactoryGenerator.java
示例14: PrivateObjectFactoryGenerator
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public PrivateObjectFactoryGenerator(BeanGenerator outline, Model model, JPackage targetPackage) {
super(outline, model, targetPackage.subPackage("impl"));
JPackage implPkg = targetPackage.subPackage("impl");
// put JAXBContextFactory into the impl package
JClass factory = outline.generateStaticClass(JAXBContextFactory.class,implPkg);
// and then put jaxb.properties to point to it
JPropertyFile jaxbProperties = new JPropertyFile("jaxb.properties");
targetPackage.addResourceFile(jaxbProperties);
jaxbProperties.add(
JAXBContext.JAXB_CONTEXT_FACTORY,
factory.fullName());
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:PrivateObjectFactoryGenerator.java
示例15: ObjectFactoryGeneratorImpl
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public ObjectFactoryGeneratorImpl( BeanGenerator outline, Model model, JPackage targetPackage ) {
this.outline = outline;
this.model = model;
this.codeModel = this.model.codeModel;
this.classRef = codeModel.ref(Class.class);
// create the ObjectFactory class skeleton
objectFactory = this.outline.getClassFactory().createClass(
targetPackage, "ObjectFactory", null );
objectFactory.annotate2(XmlRegistryWriter.class);
// generate the default constructor
//
// m1 result:
// public ObjectFactory() {}
JMethod m1 = objectFactory.constructor(JMod.PUBLIC);
m1.javadoc().append("Create a new ObjectFactory that can be used to " +
"create new instances of schema derived classes " +
"for package: " + targetPackage.name());
// add some class javadoc
objectFactory.javadoc().append(
"This object contains factory methods for each \n" +
"Java content interface and Java element interface \n" +
"generated in the " + targetPackage.name() + " package. \n" +
"<p>An ObjectFactory allows you to programatically \n" +
"construct new instances of the Java representation \n" +
"for XML content. The Java representation of XML \n" +
"content can consist of schema derived interfaces \n" +
"and classes representing the binding of schema \n" +
"type definitions, element declarations and model \n" +
"groups. Factory methods for each of these are \n" +
"provided in this class." );
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:ObjectFactoryGeneratorImpl.java
示例16: openBinary
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
StandardLocation loc;
if(fileName.endsWith(".java")) {
// Annotation Processing doesn't do the proper Unicode escaping on Java source files,
// so we can't rely on Filer.createSourceFile.
loc = SOURCE_PATH;
} else {
// put non-Java files directly to the output folder
loc = CLASS_PATH;
}
return filer.createResource(loc, pkg.name(), fileName).openOutputStream();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:FilerCodeWriter.java
示例17: openSource
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public Writer openSource(JPackage pkg, String fileName) throws IOException {
String name;
if(pkg.isUnnamed())
name = fileName;
else
name = pkg.name()+'.'+fileName;
name = name.substring(0,name.length()-5); // strip ".java"
return filer.createSourceFile(name).openWriter();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:FilerCodeWriter.java
示例18: getTargetPackage
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
/**
* Gets the specified package name (options/@package).
*/
public JPackage getTargetPackage() {
if(model.options.defaultPackage!=null)
// "-p" takes precedence over everything else
return codeModel._package(model.options.defaultPackage);
String p;
if( defaultPackage!=null )
p = defaultPackage;
else
p = getOption("package", "");
return codeModel._package(p);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:BindInfo.java
示例19: report
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
private void report(JPackage pkg, String fileName) {
String name = pkg.name().replace('.', File.separatorChar);
if(name.length()!=0) name += File.separatorChar;
name += fileName;
if(progress.isCanceled())
throw new AbortException();
progress.generatedFile(name,current++,totalFileCount);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ProgressCodeWriter.java
示例20: openBinary
import com.sun.codemodel.internal.JPackage; //导入依赖的package包/类
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
String name = fileName;
if(!pkg.isUnnamed()) name = toDirName(pkg)+name;
zip.putNextEntry(new ZipEntry(name));
return filter;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ZipCodeWriter.java
注:本文中的com.sun.codemodel.internal.JPackage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论