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


Java Model类代码示例

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


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

示例1: compilesSchema

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-XhashCode",
			"-Xequals", "-XtoString", "-Xcopyable", "-Xmergeable",
			"-Xinheritance", "-Xsetters", "-Xsetters-mode=direct",
			"-Xwildcard", "-XenumValue"
	// "-XsimpleToString"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:26,代码来源:RunPlugins.java

示例2: compilesCustomer

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
	public void compilesCustomer() throws Exception {

		new File("target/generated-sources/xjc").mkdirs();

		URL schema = getClass().getResource("/customer.xsd");
		URL binding = getClass().getResource("/customer.xjb");
		final String[] arguments = new String[] { "-xmlschema",
				schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
				"target/generated-sources/xjc", "-extension",
				"-XsimpleHashCode",
//				"-XsimpleEquals", "-XsimpleToString" 
				};

		Options options = new Options();
		options.parseArguments(arguments);
		ConsoleErrorReporter receiver = new ConsoleErrorReporter();
		Model model = ModelLoader.load(options, new JCodeModel(), receiver);
		model.generateCode(options, receiver);
		com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
		model.codeModel.build(cw);
	}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:23,代码来源:RunPluginsForCustomer.java

示例3: compilesSchema

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
	public void compilesSchema() throws Exception {

		new File("target/generated-sources/xjc").mkdirs();

		URL schema = getClass().getResource("/main.xsd");
		URL binding = getClass().getResource("/main.xjb");
		final String[] arguments = new String[] { "-xmlschema",
				schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
				"target/generated-sources/xjc", "-extension",
				"-XsimpleHashCode",
//				"-XsimpleEquals", "-XsimpleToString"
				};

		Options options = new Options();
		options.parseArguments(arguments);
		ConsoleErrorReporter receiver = new ConsoleErrorReporter();
		Model model = ModelLoader.load(options, new JCodeModel(), receiver);
		model.generateCode(options, receiver);
		com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
		model.codeModel.build(cw);
	}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:23,代码来源:RunPluginsForMain.java

示例4: compilesSchema

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/cases.xsd");
	// URL binding = getClass().getResource("/cases.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(),
			// "-b", binding.toExternalForm(),
			"-d", "target/generated-sources/xjc", "-extension",
			"-XsimpleHashCode", "-XsimpleEquals",
	// "-XsimpleToString"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:25,代码来源:RunPluginsForCases.java

示例5: compilesSchema

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-Xsimplify", "-Xsimplify-usePluralForm=true"};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:20,代码来源:RunSimplifyPlugin.java

示例6: compilesContext_V_1_1_0

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
public void compilesContext_V_1_1_0() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	final String[] arguments = new String[] { "-xmlschema",
			new File("src/main/resources/schema.xsd").toURI().toString(),
			"-d",
			"target/generated-sources/xjc", 
			"-XfixJAXB1058",
			"-extension", "-XtoString",
			"-Xequals", "-XhashCode", "-Xcopyable", "-Xmergeable"};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:22,代码来源:ExecuteJAXB1058.java

示例7: compilesSchema

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/bindings.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-Xsimplify", "-Xsimplify-usePluralForm=true"};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:20,代码来源:RunSimplifyPlugin.java

示例8: compilesSchema

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-XtoString",
			"-Xequals", "-XhashCode", "-Xcopyable", "-Xmergeable" };

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:21,代码来源:RunPlugins.java

示例9: generateExtends

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
private JClass generateExtends(ClassOutline classOutline,
		Map<String, JClass> knownClasses,
		Map<JClass, CClassInfo> knownClassInfos) {
	final JDefinedClass theClass = classOutline.implClass;
	final CPluginCustomization extendsClassCustomization = CustomizationUtils
			.findCustomization(classOutline,
					Customizations.EXTENDS_ELEMENT_NAME);
	JClass targetClass = generateExtends(theClass,
			extendsClassCustomization, knownClasses);

	final CClassInfo classInfo = classOutline.target;
	if (targetClass != null && classInfo.getBaseClass() == null
			&& classInfo.getRefBaseClass() == null) {
		final CClassInfo targetClassInfo = knownClassInfos.get(targetClass);
		if (targetClassInfo == null && classInfo.getRefBaseClass() == null) {
			final Model model = classInfo.model;
			// BIEnum as BIClass is protected too much
			final BIEnum decl = new BIEnum();
			decl.ref = targetClass.fullName();
			final CClassRef baseClass = new CClassRef(model,
					classInfo.getSchemaComponent(), decl,
					new CCustomizations());
			classInfo.setBaseClass(baseClass);
		} else if (targetClassInfo != null
				&& classInfo.getBaseClass() == null) {
			classInfo.setBaseClass(targetClassInfo);
		}
	}
	return targetClass;
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:31,代码来源:InheritancePlugin.java

示例10: postProcessReferencePropertyInfo

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
private void postProcessReferencePropertyInfo(final Model model,
		final CClassInfo classInfo, CReferencePropertyInfo property) {
	if (CustomizationUtils
			.containsPropertyCustomizationInPropertyOrClass(
					property,
					org.jvnet.jaxb2_commons.plugin.simplify.Customizations.PROPERTY_ELEMENT_NAME,
					org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_ELEMENT_PROPERTY_ELEMENT_NAME)) {
		simplifyReferencePropertyInfoAsElementPropertyInfo(model,
				classInfo, property);
	} else if (CustomizationUtils
			.containsPropertyCustomizationInPropertyOrClass(
					property,
					org.jvnet.jaxb2_commons.plugin.simplify.Customizations.PROPERTY_ELEMENT_NAME,
					org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_REFERENCE_PROPERTY_ELEMENT_NAME)) {
		simplifyReferencePropertyInfoAsReferencePropertyInfo(model,
				classInfo, property);
	}
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:19,代码来源:SimplifyPlugin.java

示例11: simplifyElementPropertyInfoAsElementPropertyInfo

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
private void simplifyElementPropertyInfoAsElementPropertyInfo(
		final Model model, final CClassInfo classInfo,
		CElementPropertyInfo property) {
	if (property.getTypes().size() > 1) {
		logger.debug(MessageFormat
				.format("Element property [{0}] has several types and will be simplified.",
						property.getName(false)));
		int index = classInfo.getProperties().indexOf(property);
		for (CTypeRef typeRef : property.getTypes()) {
			final CElementPropertyInfo elementPropertyInfo = createElementPropertyInfo(
					model, property, typeRef);
			classInfo.getProperties().add(index++, elementPropertyInfo);
		}
		classInfo.getProperties().remove(property);
	} else {
		logger.warn(MessageFormat
				.format("Element property [{0}] will not be simplified as it does not contain multiple types.",
						property.getName(false)));
	}
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:21,代码来源:SimplifyPlugin.java

示例12: simplifyReferencePropertyInfoAsReferencePropertyInfo

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
private void simplifyReferencePropertyInfoAsReferencePropertyInfo(
		final Model model, final CClassInfo classInfo,
		CReferencePropertyInfo property) {
	if (property.getElements().size() <= 1 && !property.isMixed()) {
		logger.warn(MessageFormat
				.format("Element reference property [{0}] will not be simplified as it does not contain multiple elements and is not mixed.",
						property.getName(false)));
	} else {
		logger.debug(MessageFormat
				.format("Element reference property [{0}] contains multiple elements or is mixed and will be simplified.",
						property.getName(false)));
		int index = classInfo.getProperties().indexOf(property);
		for (CElement element : property.getElements()) {
			final CReferencePropertyInfo referencePropertyInfo = createReferencePropertyInfo(
					model, property, element);
			classInfo.getProperties().add(index++, referencePropertyInfo);
		}
		if (property.isMixed()) {
			classInfo.getProperties().add(index++,
					createContentReferencePropertyInfo(model, property));
		}
		classInfo.getProperties().remove(property);
	}
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:25,代码来源:SimplifyPlugin.java

示例13: createElementPropertyInfo

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
private CElementPropertyInfo createElementPropertyInfo(final Model model,
		CElementPropertyInfo property, CTypeRef typeRef) {
	final String propertyName = createPropertyName(model, property, typeRef);
	boolean required = false;
	final CElementPropertyInfo elementPropertyInfo = new CElementPropertyInfo(
			propertyName,
			property.isCollection() ? CollectionMode.REPEATED_ELEMENT
					: CollectionMode.NOT_REPEATED, typeRef.getTarget()
					.idUse(), typeRef.getTarget().getExpectedMimeType(),
			property.getSchemaComponent(), property.getCustomizations(),
			property.getLocator(), required);
	final CAdapter adapter = property.getAdapter();
	if (adapter != null) {
		elementPropertyInfo.setAdapter(adapter);
	}
	elementPropertyInfo.getTypes().add(typeRef);
	return elementPropertyInfo;
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:19,代码来源:SimplifyPlugin.java

示例14: generateCode

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
protected Outline generateCode(final Model model)
		throws MojoExecutionException {
	if (getVerbose()) {
		getLog().info("Compiling input schema(s)...");
	}

	final Outline outline = model.generateCode(model.options,
			new LoggingErrorReceiver("Error while generating code.",
					getLog(), getVerbose()));
	if (outline == null) {
		throw new MojoExecutionException(
				"Failed to compile input schema(s)!  Error messages should have been provided.");
	} else {
		return outline;
	}
}
 
开发者ID:highsource,项目名称:maven-jaxb2-plugin,代码行数:17,代码来源:XJC21Mojo.java

示例15: generateCode

import com.sun.tools.xjc.model.Model; //导入依赖的package包/类
protected Outline generateCode(final Model model)
		throws MojoExecutionException {
	if (getVerbose()) {
		getLog().info("Compiling input schema(s)...");
	}

	final Outline outline = model.generateCode(model.options,
			new LoggingErrorReceiver("Error while generating code.",
					getLog(), getVerbose()));
	if (outline == null) {
		throw new MojoExecutionException(
				"Failed to compile input schema(s)! Error messages should have been provided.");
	} else {
		return outline;
	}
}
 
开发者ID:highsource,项目名称:maven-jaxb2-plugin,代码行数:17,代码来源:XJC22Mojo.java


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