/** * Main for cde. * * @param aMerger the a merger * @param aProgressMonitor the a progress monitor * @param aError the a error * @param inputFile the input file * @param outputDirectory the output directory * @param tds the tds * @param aCas the a cas * @throws IOException Signals that an I/O exception has occurred. */ public void mainForCde(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas) throws IOException { mainForCde(aMerger, aProgressMonitor, aError, inputFile, outputDirectory, tds, aCas, "", false, null); }
/** * Gets the java name. * * @param name the name * @return the java name */ String getJavaName(String name) { if (!hasPkgPrefix(name)) return name; String javaNameWithPkg = getJavaNameWithPkg(name); String simpleName = removePkg(javaNameWithPkg); if (getPkg(javaNameWithPkg).equals(packageName)) return simpleName; if (javaNameWithPkg.equals(imports.get(simpleName))) return simpleName; return javaNameWithPkg; }
/** * Gets the array feature value. * * @param fd the fd * @param td the td * @return the array feature value */ String getArrayFeatureValue(FeatureDescription fd, TypeDescription td) { String getSetArrayNamePart = getGetSetArrayNamePart(fd); String core = arrayCore("get", getSetArrayNamePart, getJavaRangeType(fd), fd.getName()); return castResult(getJavaRangeArrayElementType(fd), core); }
/** * Sets the array feature value. * * @param fd the fd * @param td the td * @return the string */ String setArrayFeatureValue(FeatureDescription fd, TypeDescription td) { return arrayCore("set", getGetSetArrayNamePart(fd), getJavaRangeType(fd), fd.getName()); }
Jg jg = (Jg)args[0]; TypeDescription td = (TypeDescription)args[1]; jg.packageName = jg.getJavaPkg(td); stringBuilder.append(" \n/* Apache UIMA v3 - First created by JCasGen "); stringBuilder.append(jg.getDate()); stringBuilder.append(" */\n\n"); if (0 != jg.packageName.length()) { jg.getString("pkgMissing", new Object[] {td.getName()}), null); stringBuilder.append("\nimport java.lang.invoke.CallSite;\nimport java.lang.invoke.MethodHandle;\n\nimport org.apache.uima.cas.impl.CASImpl;\nimport org.apache.uima.cas.impl.TypeImpl;\nimport org.apache.uima.cas.impl.TypeSystemImpl;\nimport org.apache.uima.jcas.JCas; \nimport org.apache.uima.jcas.JCasRegistry;\n\n\n"); for(Iterator i=jg.collectImports(td, false).iterator(); i.hasNext();) { stringBuilder.append("import "); stringBuilder.append((String)i.next()); String typeName = jg.getJavaName(td); stringBuilder.append(jg.nullBlank(td.getDescription())); stringBuilder.append("\n * Updated by JCasGen "); stringBuilder.append(jg.getDate()); stringBuilder.append("\n * XML source: "); stringBuilder.append(jg.xmlSourceFileName); stringBuilder.append(typeName); stringBuilder.append(" extends "); stringBuilder.append(jg.getJavaName(td.getSupertypeName())); stringBuilder.append(" {\n \n /** @generated\n * @ordered \n */\n @SuppressWarnings (\"hiding\")\n public final static String _TypeName = \""); stringBuilder.append(jg.getJavaNameWithPkg(td.getName())); stringBuilder.append("\";\n \n /** @generated\n * @ordered \n */\n @SuppressWarnings (\"hiding\")\n public final static int typeIndexID = JCasRegistry.register("); stringBuilder.append(typeName);
error.newError(IError.ERROR, getString("sourceArgNeedsDirectory", new Object[] { inputFile }), null); error.newError(IError.ERROR, getString("fileNotFound", new Object[] { inputFile }), null); File file = new File(inputFile); if (!file.exists()) { error.newError(IError.ERROR, getString("fileNotFound", new Object[] { inputFile }), null); error.newError(IError.ERROR, getString("sourceArgNeedsDirectory", new Object[] { inputFile }), null); progressMonitor.subTask(getString("ReadingDescriptorAndCreatingTypes", new Object[] { inputFile })); if (!aeSpecifier.isPrimitive()) typeSystemDescription = CasCreationUtils.mergeDelegateAnalysisEngineTypeSystems( aeSpecifier, createResourceManager(), mergedTypesAddingFeatures); else typeSystemDescription = mergeTypeSystemImports(aeSpecifier .getAnalysisEngineMetaData().getTypeSystem()); typeSystemDescription = mergeTypeSystemImports(((TypeSystemDescription) specifier)); else { error.newError(IError.ERROR, getString("fileDoesntParse", new Object[] { inputFile }), null); error.newError(IError.WARN, getString("typesHaveFeaturesAdded", new Object[] { makeMergeMessage(mergedTypesAddingFeatures) }), null);
@Override public Object run(Object object) { try { final String[] arguments = (String[]) object; final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final Jg jg = new Jg(); IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor progressMonitor) throws CoreException { jg.main0(arguments, new MergerImpl(), null, // no progressMonitor, new EP_LogThrowErrorImpl()); } }; workspace.run(runnable, null); return Integer.valueOf(0); } catch (Exception exception) { exception.printStackTrace(); } return Integer.valueOf(1); }
continue; if (limitJCasGenToProjectScope && isOutOfScope(td, projectPathDir)) { Set<String> mt = mergedTypesAddingFeatures.get(td.getName()); if (null == mt) { sb.append(" ").append(p).append('\n'); error.newError(IError.ERROR, getString("limitingButTypeWasExtended", new Object[] { td.getName(), sb.toString()}), null); continue; if (null != builtInFeatures) { generatedBuiltInTypes.add(td.getName()); List<FeatureDescription> newFeatures = setDifference(td.getFeatures(), builtInFeatures); int newFeaturesSize = newFeatures.size(); if (newFeaturesSize > 0) { generateClassesFromTemplate(td, outputDirectory, jcasTypeInstance);
/** * Generate type classes from the specified templates. * * @param td TypeDescription object * @param outputDirectory output directory * @param jcasTypeInstance Template instance used to generate class * @return void * @throws IOException - */ private void generateClassesFromTemplate(TypeDescription td, String outputDirectory, IJCasTypeTemplate jcasTypeInstance) throws IOException { simpleClassName = removePkg(getJavaName(td)); generateClass(progressMonitor, outputDirectory, td, jcasTypeInstance.generate(new Object[] { this, td }), getJavaName(td), merger); // simpleClassName = removePkg(getJavaName_Type(td)); // generateClass(progressMonitor, outputDirectory, td, jcas_TypeInstance.generate(new Object[] { // this, td }), getJavaName_Type(td), merger); }
@Override public void run() { jg.main0(new String[] { "-jcasgeninput", inFileName, "-jcasgenoutput", outDirName }, jg.merger, new GuiProgressMonitor(), new GuiErrorImpl()); } };
throws IOException { String pkgName = getJavaPkg(td); String qualifiedClassName = (0 != pkgName.length()) ? pkgName + "." + className : className; String targetContainer = outputDirectory + '/' + pkgName.replace('.', '/'); } else { if (targetFile.exists()) { progressMonitorGenerateClass.subTask(getString("replacingTarget", new Object[] { qualifiedClassName })); } else progressMonitorGenerateClass.subTask(getString("creatingTarget", new Object[] { qualifiedClassName })); (new File(targetContainer)).mkdirs();
TypeInfo(String xmlName, String javaName) { this.xmlName = xmlName; this.javaNameWithPkg = javaName; this.javaName = org.apache.uima.tools.jcasgen.Jg.removePkg(javaName); this.isArray = false; this.arrayElNameWithPkg = ""; }
/** * Creates the resource manager. * * @return the resource manager */ public ResourceManager createResourceManager() { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); if (classPath != null && classPath.trim().length() > 0) { try { resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true); } catch (MalformedURLException e1) { error.newError(IError.ERROR, getString("Internal Error", null), e1); } } else { resourceManager.setExtensionClassLoader(this.getClass().getClassLoader(), true); } return resourceManager; }
/** * Adds the built in type info. * * @param casName the cas name * @param javaName the java name */ static private void addBuiltInTypeInfo(String casName, String javaName) { addBuiltInTypeInfo(casName, javaName, null); }
final Jg jg = new Jg(); final TypeDescription[] types = mergedTypeSystemDescription.getTypes(); final String outputDirectory = getPrimarySourceFolder().getLocation().toOSString();
@Override public void run(IProgressMonitor progressMonitor) throws CoreException { jg.main0(arguments, new MergerImpl(), null, // no progressMonitor, new EP_LogThrowErrorImpl()); } };
/** * Instantiates a new type info. * * @param xmlName the xml name * @param javaName the java name */ TypeInfo(String xmlName, String javaName) { this.xmlName = xmlName; this.javaNameWithPkg = javaName; this.javaName = Jg.removePkg(javaName); this.isArray = false; this.arrayElNameWithPkg = ""; }
.createCompilationUnitForContents(sourceContents); if (targetFile.exists()) { progressMonitor.subTask(jg.getString("updatingTarget", new Object[] { targetClassName })); jMerger.setTargetCompilationUnit(jMerger.createCompilationUnitForURI(targetPath)); } catch (NullPointerException e) { jg.error.newError(IError.ERROR, jg.getString("nullPtr", new Object[] { targetClassName }), e); progressMonitor.subTask(jg.getString("creatingTarget", new Object[] { targetClassName })); (new File(targetContainer)).mkdirs(); FileWriter fw = new FileWriter(targetPath);