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


Java JPackage.remove方法代码示例

本文整理汇总了Java中com.sun.codemodel.JPackage.remove方法的典型用法代码示例。如果您正苦于以下问题:Java JPackage.remove方法的具体用法?Java JPackage.remove怎么用?Java JPackage.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.codemodel.JPackage的用法示例。


在下文中一共展示了JPackage.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeUnique

import com.sun.codemodel.JPackage; //导入方法依赖的package包/类
private String makeUnique(String className, JPackage _package) {
    try {
        JDefinedClass _class = _package._class(className);
        _package.remove(_class);
        return className;
    } catch (JClassAlreadyExistsException e) {
        return makeUnique(className + "_", _package);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ObjectRule.java

示例2: createInterfaceDeclaration

import com.sun.codemodel.JPackage; //导入方法依赖的package包/类
private DefinedInterfaceOutline createInterfaceDeclaration(final XSDeclaration groupDecl) throws SAXException {
	final PackageOutline packageOutline = findPackageForNamespace(groupDecl.getTargetNamespace());
	if (packageOutline == null) {
		this.pluginContext.errorHandler.error(new SAXParseException(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("error.package-not-found"), groupDecl.getTargetNamespace()), groupDecl.getLocator()));
		return null;
	}

	final JPackage container = packageOutline._package();
	final ClassOutline dummyImplementation = this.pluginContext.classesBySchemaComponent.get(PluginContext.getQName(groupDecl));
	if (dummyImplementation == null) {
		this.pluginContext.errorHandler.error(new SAXParseException(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("error.no-implementation"), this.pluginContext.outline.getModel().getNameConverter().toClassName(groupDecl.getName()), groupDecl.getTargetNamespace(), groupDecl.getName()), groupDecl.getLocator()));
		return null;
	}

	final String interfaceName = dummyImplementation.implClass.name();
	container.remove(dummyImplementation.implClass);
	final JDefinedClass groupInterface;
	final JDefinedClass supportInterface;
	try {
		groupInterface = container._interface(JMod.PUBLIC, interfaceName);
		supportInterface = this.settings.isGeneratingSupportInterface() ? container._interface(JMod.PUBLIC, interfaceName + this.settings.getSupportInterfaceNameSuffix())._implements(groupInterface) : null;
	} catch (final JClassAlreadyExistsException e) {
		this.pluginContext.errorHandler.error(new SAXParseException(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("error.interface-exists"), interfaceName, ""), groupDecl.getLocator()));
		return null;
	}
	final DefinedInterfaceOutline interfaceDecl = new DefinedInterfaceOutline(groupDecl, groupInterface, dummyImplementation, supportInterface);

	// Generate Javadoc with schema fragment
	final StringWriter out = new StringWriter();
	out.write("<pre>\n");
	final SchemaWriter sw = new SchemaWriter(new JavadocEscapeWriter(out));
	groupDecl.visit(sw);
	out.write("</pre>");

	final JDocComment comment = groupInterface.javadoc();
	comment.append(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("comment.generated-from-xs-decl.header")).
			append("\n").
			append(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("comment.generated-from-xs-decl.qname"),
					groupDecl.getTargetNamespace(),
					groupDecl.getName())).
			append("\n").
			append(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("comment.generated-from-xs-decl.locator"),
					groupDecl.getLocator().getSystemId(),
					groupDecl.getLocator().getLineNumber(),
					groupDecl.getLocator().getColumnNumber()))
			.append("\n")
			.append(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("comment.generated-from-xs-decl.source"))
			.append("\n")
			.append(out.toString());


	for (final PropertyUse propertyUse : findChildDecls(groupDecl)) {
		final FieldOutline field = findField(dummyImplementation, propertyUse);
		if (field != null) {
			generateProperty(interfaceDecl, field);
		}
	}

	if(this.declareVisitMethod) {
		final JDefinedClass target = supportInterface != null ? supportInterface : groupInterface;
		target.method(JMod.NONE, target, this.pluginContext.findPlugin(MetaPlugin.class).getVisitMethodName()).param(JMod.FINAL, PropertyVisitor.class, "visitor_");
	}

	return interfaceDecl;
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:66,代码来源:GroupInterfaceGenerator.java


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