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


Java JClassAlreadyExistsException.printStackTrace方法代码示例

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


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

示例1: getNamespaceClass

import com.sun.codemodel.JClassAlreadyExistsException; //导入方法依赖的package包/类
public JDefinedClass getNamespaceClass(String namespace, ParsingContext context) {
	if (namespace == null) {
		return null;
	}
	
	JDefinedClass ret = namespaceClasses.get(namespace);
	if (ret == null) {
		try {
			ret = context.getCm()._class("generated." + namespace);
			ret.init().add(context.getCm().ref(BridJ.class).staticInvoke("register"));
			Map<String, String> nsToLib =
					(Map<String, String>) context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE_TO_LIB);
			String libName = nsToLib.get(namespace);
			if (libName != null) {
				ret.annotate(Library.class).param("value", libName);
			}
			namespaceClasses.put(namespace, ret);
		} catch (JClassAlreadyExistsException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return ret;
}
 
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:25,代码来源:TypeRegistry.java

示例2: createProject

import com.sun.codemodel.JClassAlreadyExistsException; //导入方法依赖的package包/类
/**
 * This method creates a new java project based on the user inputs, captured in WizardInput object.
 * The new project is created in the current workspace.
 * @param wizardInput
 * @return IJavaProject
 * @throws CoreException
 * @throws IOException
 **/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(wizardInput.getProjectName());
	project.create(null);
	project.open(null);		
	IProjectDescription description = project.getDescription();
	description.setNatureIds(new String[] { JavaCore.NATURE_ID });
	project.setDescription(description, null);
	IJavaProject javaProject = JavaCore.create(project); 
	IFolder binFolder = project.getFolder("bin");
	binFolder.create(false, true, null);
	javaProject.setOutputLocation(binFolder.getFullPath(), null);
	List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
	IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
	LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
	for (LibraryLocation element : locations) {
	 entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
	}
	InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
    IFile jarFile = project.getFile("soot-trunk.jar");
    jarFile.create(is, false, null);
    IPath path = jarFile.getFullPath();
    entries.add(JavaCore.newLibraryEntry(path, null, null));
	javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);		
	IFolder sourceFolder = project.getFolder("src");
	sourceFolder.create(false, true, null);
	IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
	IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
	newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
	javaProject.setRawClasspath(newEntries, null);
	String filepath = sourceFolder.getLocation().toOSString();
	File file = new File(filepath);
	wizardInput.setFile(file);
	try {
		CodeGenerator.generateSource(wizardInput);
	} catch (JClassAlreadyExistsException e) {
		e.printStackTrace();
	}
	sourceFolder.refreshLocal(1, null);
	javaProject.open(null);
	return javaProject;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:54,代码来源:ProjectGenerator.java

示例3: ConstantsCodeGenerator

import com.sun.codemodel.JClassAlreadyExistsException; //导入方法依赖的package包/类
public ConstantsCodeGenerator() {
	try {
		jConstantsClass = this.getJavaPackage()._class(JMod.PUBLIC | JMod.FINAL, "Constant", ClassType.CLASS);
	} catch (JClassAlreadyExistsException e) {
		e.printStackTrace();
	}
}
 
开发者ID:l3ug1m,项目名称:thrift-java-compiler,代码行数:8,代码来源:ConstantsCodeGenerator.java

示例4: propertyOrder

import com.sun.codemodel.JClassAlreadyExistsException; //导入方法依赖的package包/类
@Override
public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) {
    //We just want to make sure we avoid infinite loops
    clazz.annotate(JsonDeserialize.class)
            .param("using", JsonDeserializer.None.class);
    clazz.annotate(ToString.class);
    clazz.annotate(EqualsAndHashCode.class);
    try {
        JAnnotationArrayMember inlines = clazz.annotate(Buildable.class)
                .param("editableEnabled", true)
                .param("validationEnabled", true)
                .param("generateBuilderPackage", true)
                .param("builderPackage", "io.fabric8.docker.api.builder")
                .paramArray("inline");

        inlines.annotate(Inline.class)
                .param("type", new JCodeModel()._class("io.fabric8.docker.api.model.Doneable"))
                .param("prefix", "Doneable")
                .param("value", "done");

        //Let's get our hands dirty and add annotations so that we generate custom Inline methods
        if (clazz.name().equals("NetworkCreate")) {
            inlines.annotate(Inline.class)
                    .param("type", new JCodeModel()._class("io.fabric8.docker.api.model.Doneable"))
                    .param("returnType", new JCodeModel()._class("io.fabric8.docker.api.model.NetworkCreateResponse"))
                    .param("name", "InlineNetworkCreate")
                    .param("value", "done");
        }


        if (clazz.name().equals("AuthConfig")) {
            addInline(inlines, "InlineAuth", "java.lang.Boolean");
        }

        if (clazz.name().equals("NetworkCreate")) {
            addInline(inlines, "InlineNetworkCreate", "io.fabric8.docker.api.model.NetworkCreateResponse");
        }

        if (clazz.name().equals("VolumeCreateRequest")) {
            addInline(inlines, "InlineVolumeCreate", "io.fabric8.docker.api.model.Volume");
        }

        if (clazz.name().equals("ExecConfig")) {
            addInline(inlines, "InlineExecConfig", "io.fabric8.docker.api.model.ContainerExecCreateResponse");
        }


    } catch (JClassAlreadyExistsException e) {
        e.printStackTrace();
    }
}
 
开发者ID:fabric8io,项目名称:docker-client,代码行数:52,代码来源:DockerTypeAnnotator.java

示例5: parseEnumeration

import com.sun.codemodel.JClassAlreadyExistsException; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void parseEnumeration(Element root, ParsingContext context) {
	String enumName = root.getAttributeValue("name");
	String enumCType = root.getAttributeValue("type", Constants.GIR_XMLNS_C);
	JCodeModel cm = (JCodeModel)context.getCmNode();
	
	try {
		String enumFqcn = context.getCurrentPackage() + '.' + context.getExtra(Constants.CONTEXT_EXTRA_PREFIX) + NameUtils.neutralizeKeyword(enumName);
		JDefinedClass enumClass = cm._class(enumFqcn, ClassType.ENUM);
		System.out.println("New enum: " + enumFqcn);
		
		enumClass.init().add(cm.ref(BridJ.class).staticInvoke("register"));
		enumClass.annotate(Library.class).param("value", context.getLibraryName());

		Set<String> foundTypes = (Set<String>)context.getExtra(Constants.CONTEXT_EXTRA_DEFINED_TYPES);
		foundTypes.add("" + context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE) + '.' + enumName);
		
		//implements IntValuedEnum<ThisEnum>
		JClass intValuedEnumClass = context.getCm().ref(org.bridj.IntValuedEnum.class);
		JClass concreteIntValuedEnumClass = intValuedEnumClass.narrow(enumClass);
		enumClass._implements(concreteIntValuedEnumClass);
		
		//value field, public final long
		JFieldVar valueField = enumClass.field(JMod.PUBLIC | JMod.FINAL, long.class, "value");
		
		//arbitrary value constructor
		JMethod ctor = enumClass.constructor(JMod.NONE);
		JVar ctorParam = ctor.param(long.class, "value");
		JBlock ctorBody = ctor.body();
		ctorBody.assign(JExpr._this().ref(valueField), ctorParam);
		
		//value getter
		JMethod valueGetter = enumClass.method(JMod.PUBLIC, long.class, "value");
		valueGetter.body()._return(JExpr._this().ref(valueField));
		
		//iterator method
		JClass iteratorClass = cm.ref(Iterator.class).narrow(enumClass);
		JMethod iteratorMethod = enumClass.method(JMod.PUBLIC, iteratorClass, "iterator");
		JClass collectionsClass = cm.ref(Collections.class);
		JInvocation iteratorCall = collectionsClass.staticInvoke("singleton").arg(JExpr._this()).invoke("iterator");
		iteratorMethod.body()._return(iteratorCall);
		
		//fromValue method
		JMethod fromValue = enumClass.method(JMod.PUBLIC | JMod.STATIC, concreteIntValuedEnumClass, "fromValue");
		
		JVar fromValueParam = fromValue.param(int.class, "value");
		JClass flagSetClass = cm.ref(FlagSet.class);
		JInvocation fromValueCall = flagSetClass.staticInvoke("fromValue")
				.arg(fromValueParam)
				.arg(enumClass.staticInvoke("values"));
		fromValue.body()._return(fromValueCall);
		
		//enum instances
		parseElements(root.getChildElements(), context.withCmNode(enumClass));
		
		//register the type
		ConvertedType regType = new ConvertedType(
				cm,
				(String)context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE),
				enumName,
				enumCType,
				true
		);
		regType.setJType(cm.ref(IntValuedEnum.class).narrow(enumClass));
		context.registerType(regType);
		
	} catch (JClassAlreadyExistsException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:72,代码来源:GirParser.java

示例6: parseCallback

import com.sun.codemodel.JClassAlreadyExistsException; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void parseCallback(Element root, ParsingContext context) {
	//Note: I expect never getting here from an anonymous callback type for now
	String name = root.getAttributeValue("name");
	Set<String> foundTypes = (Set<String>)context.getExtra(Constants.CONTEXT_EXTRA_DEFINED_TYPES);
	foundTypes.add("" + context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE) + '.' + name);
	
	ParsingContext nextContext = context.copy();
	parseElements(root.getChildElements(), nextContext);
	// The context should now have the return type, and parameter list.
	
	ConvertedType returnType = (ConvertedType) nextContext.getExtra(Constants.CONTEXT_EXTRA_RETURN_TYPE);
	List<ParameterDescriptor> parametersList = (List<ParameterDescriptor>) nextContext.getExtra(Constants.CONTEXT_EXTRA_PARAM_TYPES);
	
	if (checkUndefined(root, nextContext)) {
		return;
	}
	
	if (checkStructByValue(returnType, parametersList)) {
		System.out.println("Skipped callback type " + name + " because it takes or returns struct by value");
		return;
	}
	
	//Abstract class
	//XXX: why neutralize, or why not together with the prefix?
	String className = context.getCurrentPackage() + '.' + context.getExtra(Constants.CONTEXT_EXTRA_PREFIX) + NameUtils.neutralizeKeyword(name);
	JDefinedClass callbackType;
	try {
		callbackType = context.getCm()._class(JMod.PUBLIC | JMod.ABSTRACT, className, ClassType.CLASS);
	} catch (JClassAlreadyExistsException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return;
	}
	callbackType._extends(context.getCm().ref(Callback.class).narrow(callbackType));
	
	//apply() method
	JMethod applyMethod = callbackType.method(JMod.PUBLIC | JMod.ABSTRACT, returnType.getJType(), "apply");
	for (ParameterDescriptor param : parametersList) {
		applyMethod.param(param.getType().getJType(), param.getName());
	}
	
	ConvertedType convType = new ConvertedType(
			context.getCm(),
			(String)context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE),
			name,
			root.getAttributeValue("type",Constants.GIR_XMLNS_C),
			false
	);
	convType.setJType(context.getCm().ref(Pointer.class).narrow(callbackType));
	context.registerType(convType);
}
 
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:53,代码来源:GirParser.java


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