private void xmlWriteDoclet(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException { //set the packages and source files List<String> packages= new ArrayList<>(); List<String> sourcefiles= new ArrayList<>(); sortSourceElement(store.getSourceElements(), sourcefiles, packages); if (!packages.isEmpty()) xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages)); if (!sourcefiles.isEmpty()) xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles)); xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath())); xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath())); xmlJavadocDesc.setAttribute(store.VISIBILITY, store.getAccess()); Element doclet= document.createElement("doclet"); //$NON-NLS-1$ xmlJavadocDesc.appendChild(doclet); doclet.setAttribute(store.NAME, store.getDocletName()); doclet.setAttribute(store.PATH, store.getDocletPath()); String str= store.getOverview(); if (str.length() > 0) xmlJavadocDesc.setAttribute(store.OVERVIEW, str); str= store.getAdditionalParams(); if (str.length() > 0) xmlJavadocDesc.setAttribute(store.EXTRAOPTIONS, str); }
public Element createXML(JavadocOptionsManager store) throws ParserConfigurationException { DocumentBuilder docBuilder= null; DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); docBuilder= factory.newDocumentBuilder(); Document document= docBuilder.newDocument(); // Create the document Element project= document.createElement("project"); //$NON-NLS-1$ document.appendChild(project); project.setAttribute("default", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element javadocTarget= document.createElement("target"); //$NON-NLS-1$ project.appendChild(javadocTarget); javadocTarget.setAttribute("name", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element xmlJavadocDesc= document.createElement("javadoc"); //$NON-NLS-1$ javadocTarget.appendChild(xmlJavadocDesc); if (!store.isFromStandard()) xmlWriteDoclet(store, document, xmlJavadocDesc); else xmlWriteJavadocStandardParams(store, document, xmlJavadocDesc); return xmlJavadocDesc; }
private void xmlWriteJavadocStandardParams(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException { String destination= getPathString(Path.fromOSString(store.getDestination())); xmlJavadocDesc.setAttribute(store.SOURCE, store.getSource()); xmlJavadocDesc.setAttribute(store.USE, booleanToString(store.getBoolean("use"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NOTREE, booleanToString(store.getBoolean("notree"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NONAVBAR, booleanToString(store.getBoolean("nonavbar"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NOINDEX, booleanToString(store.getBoolean("noindex"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.SPLITINDEX, booleanToString(store.getBoolean("splitindex"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.AUTHOR, booleanToString(store.getBoolean("author"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.VERSION, booleanToString(store.getBoolean("version"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NODEPRECATEDLIST, booleanToString(store.getBoolean("nodeprecatedlist"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NODEPRECATED, booleanToString(store.getBoolean("nodeprecated"))); //$NON-NLS-1$ sortSourceElement(store.getSourceElements(), sourcefiles, packages); if (!packages.isEmpty()) xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages)); xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles)); xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath())); xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath()));
private String getPathString(IPath fullPath) { if (fBasePath == null || !hasSameDevice(fullPath, fBasePath)) { return fullPath.toOSString(); } int matchingSegments= fBasePath.matchingFirstSegments(fullPath); if (fBasePath.segmentCount() == matchingSegments) { return getRelativePath(fullPath, matchingSegments); } for (int i= 0; i < fJavaProjects.length; i++) { IProject proj= fJavaProjects[i].getProject(); IPath projLoc= proj.getLocation(); if (projLoc != null && projLoc.segmentCount() <= matchingSegments && projLoc.isPrefixOf(fullPath)) { return getRelativePath(fullPath, matchingSegments); } } IPath workspaceLoc= ResourcesPlugin.getWorkspace().getRoot().getLocation(); if (workspaceLoc.segmentCount() <= matchingSegments && workspaceLoc.isPrefixOf(fullPath)) { return getRelativePath(fullPath, matchingSegments); } return fullPath.toOSString(); }
private String getPathString(IPath[] paths) { StringBuilder buf= new StringBuilder(); for (int i= 0; i < paths.length; i++) { if (buf.length() != 0) { buf.append(File.pathSeparatorChar); } buf.append(getPathString(paths[i])); } if (buf.length() == 0) { buf.append('.'); } return buf.toString(); }
public Element createXML(IJavaProject[] projects) throws CoreException { if (fAntpath.length() > 0) { try { IPath filePath= Path.fromOSString(fAntpath); IPath directoryPath= filePath.removeLastSegments(1); IPath basePath= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (root.findFilesForLocationURI(URIUtil.toURI(filePath.makeAbsolute())).length > 0) { basePath= directoryPath; // only do relative path if ant file is stored in the workspace } JavadocWriter writer= new JavadocWriter(basePath, projects); return writer.createXML(this); } catch (ParserConfigurationException e) { String message= JavadocExportMessages.JavadocOptionsManager_createXM_error; throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e)); } } return null; }
JavadocWriter writer= new JavadocWriter(objectStreamOutput, encoding, basePath, projects); writer.writeXML(this); return file;
private void xmlWriteJavadocStandardParams(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException { String destination= getPathString(Path.fromOSString(store.getDestination())); xmlJavadocDesc.setAttribute(store.SOURCE, store.getSource()); xmlJavadocDesc.setAttribute(store.USE, booleanToString(store.getBoolean("use"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NOTREE, booleanToString(store.getBoolean("notree"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NONAVBAR, booleanToString(store.getBoolean("nonavbar"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NOINDEX, booleanToString(store.getBoolean("noindex"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.SPLITINDEX, booleanToString(store.getBoolean("splitindex"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.AUTHOR, booleanToString(store.getBoolean("author"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.VERSION, booleanToString(store.getBoolean("version"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NODEPRECATEDLIST, booleanToString(store.getBoolean("nodeprecatedlist"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NODEPRECATED, booleanToString(store.getBoolean("nodeprecated"))); //$NON-NLS-1$ sortSourceElement(store.getSourceElements(), sourcefiles, packages); if (!packages.isEmpty()) xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages)); xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles)); xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath())); xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath()));
private String getPathString(IPath fullPath) { if (fBasePath == null || !hasSameDevice(fullPath, fBasePath)) { return fullPath.toOSString(); } int matchingSegments= fBasePath.matchingFirstSegments(fullPath); if (fBasePath.segmentCount() == matchingSegments) { return getRelativePath(fullPath, matchingSegments); } for (int i= 0; i < fJavaProjects.length; i++) { IProject proj= fJavaProjects[i].getProject(); IPath projLoc= proj.getLocation(); if (projLoc != null && projLoc.segmentCount() <= matchingSegments && projLoc.isPrefixOf(fullPath)) { return getRelativePath(fullPath, matchingSegments); } } IPath workspaceLoc= ResourcesPlugin.getWorkspace().getRoot().getLocation(); if (workspaceLoc.segmentCount() <= matchingSegments && workspaceLoc.isPrefixOf(fullPath)) { return getRelativePath(fullPath, matchingSegments); } return fullPath.toOSString(); }
private String getPathString(IPath[] paths) { StringBuffer buf= new StringBuffer(); for (int i= 0; i < paths.length; i++) { if (buf.length() != 0) { buf.append(File.pathSeparatorChar); } buf.append(getPathString(paths[i])); } if (buf.length() == 0) { buf.append('.'); } return buf.toString(); }
public Element createXML(IJavaProject[] projects) throws CoreException { if (fAntpath.length() > 0) { try { IPath filePath= Path.fromOSString(fAntpath); IPath directoryPath= filePath.removeLastSegments(1); IPath basePath= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (root.findFilesForLocationURI(URIUtil.toURI(filePath.makeAbsolute())).length > 0) { basePath= directoryPath; // only do relative path if ant file is stored in the workspace } JavadocWriter writer= new JavadocWriter(basePath, projects); return writer.createXML(this); } catch (ParserConfigurationException e) { String message= JavadocExportMessages.JavadocOptionsManager_createXM_error; throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e)); } } return null; }
private void xmlWriteJavadocStandardParams(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException { String destination= getPathString(Path.fromOSString(store.getDestination())); xmlJavadocDesc.setAttribute(store.SOURCE, store.getSource()); xmlJavadocDesc.setAttribute(store.USE, booleanToString(store.getBoolean("use"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NOTREE, booleanToString(store.getBoolean("notree"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NONAVBAR, booleanToString(store.getBoolean("nonavbar"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NOINDEX, booleanToString(store.getBoolean("noindex"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.SPLITINDEX, booleanToString(store.getBoolean("splitindex"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.AUTHOR, booleanToString(store.getBoolean("author"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.VERSION, booleanToString(store.getBoolean("version"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NODEPRECATEDLIST, booleanToString(store.getBoolean("nodeprecatedlist"))); //$NON-NLS-1$ xmlJavadocDesc.setAttribute(store.NODEPRECATED, booleanToString(store.getBoolean("nodeprecated"))); //$NON-NLS-1$ sortSourceElement(store.getSourceElements(), sourcefiles, packages); if (!packages.isEmpty()) xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages)); xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles)); xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath())); xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath()));
private void xmlWriteDoclet(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException { //set the packages and source files List<String> packages= new ArrayList<>(); List<String> sourcefiles= new ArrayList<>(); sortSourceElement(store.getSourceElements(), sourcefiles, packages); if (!packages.isEmpty()) xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages)); if (!sourcefiles.isEmpty()) xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles)); xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath())); xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath())); xmlJavadocDesc.setAttribute(store.VISIBILITY, store.getAccess()); Element doclet= document.createElement("doclet"); //$NON-NLS-1$ xmlJavadocDesc.appendChild(doclet); doclet.setAttribute(store.NAME, store.getDocletName()); doclet.setAttribute(store.PATH, store.getDocletPath()); String str= store.getOverview(); if (str.length() > 0) xmlJavadocDesc.setAttribute(store.OVERVIEW, str); str= store.getAdditionalParams(); if (str.length() > 0) xmlJavadocDesc.setAttribute(store.EXTRAOPTIONS, str); }
public Element createXML(JavadocOptionsManager store) throws ParserConfigurationException { DocumentBuilder docBuilder= null; DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); docBuilder= factory.newDocumentBuilder(); Document document= docBuilder.newDocument(); // Create the document Element project= document.createElement("project"); //$NON-NLS-1$ document.appendChild(project); project.setAttribute("default", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element javadocTarget= document.createElement("target"); //$NON-NLS-1$ project.appendChild(javadocTarget); javadocTarget.setAttribute("name", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element xmlJavadocDesc= document.createElement("javadoc"); //$NON-NLS-1$ javadocTarget.appendChild(xmlJavadocDesc); if (!store.isFromStandard()) xmlWriteDoclet(store, document, xmlJavadocDesc); else xmlWriteJavadocStandardParams(store, document, xmlJavadocDesc); return xmlJavadocDesc; }
private String getPathString(IPath fullPath) { if (fBasePath == null || !hasSameDevice(fullPath, fBasePath)) { return fullPath.toOSString(); } int matchingSegments= fBasePath.matchingFirstSegments(fullPath); if (fBasePath.segmentCount() == matchingSegments) { return getRelativePath(fullPath, matchingSegments); } for (int i= 0; i < fJavaProjects.length; i++) { IProject proj= fJavaProjects[i].getProject(); IPath projLoc= proj.getLocation(); if (projLoc != null && projLoc.segmentCount() <= matchingSegments && projLoc.isPrefixOf(fullPath)) { return getRelativePath(fullPath, matchingSegments); } } IPath workspaceLoc= ResourcesPlugin.getWorkspace().getRoot().getLocation(); if (workspaceLoc.segmentCount() <= matchingSegments && workspaceLoc.isPrefixOf(fullPath)) { return getRelativePath(fullPath, matchingSegments); } return fullPath.toOSString(); }
private String getPathString(IPath[] paths) { StringBuffer buf= new StringBuffer(); for (int i= 0; i < paths.length; i++) { if (buf.length() != 0) { buf.append(File.pathSeparatorChar); } buf.append(getPathString(paths[i])); } if (buf.length() == 0) { buf.append('.'); } return buf.toString(); }
private void xmlWriteDoclet(JavadocOptionsManager store, Document document, Element xmlJavadocDesc) throws DOMException { //set the packages and source files List packages= new ArrayList(); List sourcefiles= new ArrayList(); sortSourceElement(store.getSourceElements(), sourcefiles, packages); if (!packages.isEmpty()) xmlJavadocDesc.setAttribute(store.PACKAGENAMES, toSeparatedList(packages)); if (!sourcefiles.isEmpty()) xmlJavadocDesc.setAttribute(store.SOURCEFILES, toSeparatedList(sourcefiles)); xmlJavadocDesc.setAttribute(store.SOURCEPATH, getPathString(store.getSourcepath())); xmlJavadocDesc.setAttribute(store.CLASSPATH, getPathString(store.getClasspath())); xmlJavadocDesc.setAttribute(store.VISIBILITY, store.getAccess()); Element doclet= document.createElement("doclet"); //$NON-NLS-1$ xmlJavadocDesc.appendChild(doclet); doclet.setAttribute(store.NAME, store.getDocletName()); doclet.setAttribute(store.PATH, store.getDocletPath()); String str= store.getOverview(); if (str.length() > 0) xmlJavadocDesc.setAttribute(store.OVERVIEW, str); str= store.getAdditionalParams(); if (str.length() > 0) xmlJavadocDesc.setAttribute(store.EXTRAOPTIONS, str); }
public void writeXML(JavadocOptionsManager store) throws ParserConfigurationException, TransformerException { DocumentBuilder docBuilder= null; DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); docBuilder= factory.newDocumentBuilder(); Document document= docBuilder.newDocument(); // Create the document Element project= document.createElement("project"); //$NON-NLS-1$ document.appendChild(project); project.setAttribute("default", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element javadocTarget= document.createElement("target"); //$NON-NLS-1$ project.appendChild(javadocTarget); javadocTarget.setAttribute("name", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element xmlJavadocDesc= document.createElement("javadoc"); //$NON-NLS-1$ javadocTarget.appendChild(xmlJavadocDesc); if (!store.isFromStandard()) xmlWriteDoclet(store, document, xmlJavadocDesc); else xmlWriteJavadocStandardParams(store, document, xmlJavadocDesc); // Write the document to the stream Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, fEncoding); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); //$NON-NLS-1$ //$NON-NLS-2$ DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(fOutputStream); transformer.transform(source, result); }
private void sortSourceElement(IJavaElement[] iJavaElements, List sourcefiles, List packages) { for (int i= 0; i < iJavaElements.length; i++) { IJavaElement element= iJavaElements[i]; IPath p= element.getResource().getLocation(); if (p == null) continue; if (element instanceof ICompilationUnit) { String relative= getPathString(p); sourcefiles.add(relative); } else if (element instanceof IPackageFragment) { packages.add(element.getElementName()); } } }
private void sortSourceElement(IJavaElement[] iJavaElements, List<String> sourcefiles, List<String> packages) { for (int i= 0; i < iJavaElements.length; i++) { IJavaElement element= iJavaElements[i]; IPath p= element.getResource().getLocation(); if (p == null) continue; if (element instanceof ICompilationUnit) { String relative= getPathString(p); sourcefiles.add(relative); } else if (element instanceof IPackageFragment) { packages.add(element.getElementName()); } } }