org.apache.ivy.util.XMLHelper Java Examples
The following examples show how to use
org.apache.ivy.util.XMLHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IvyXmlModuleDescriptorParser.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void parse() throws ParseException, IOException { getResource().withContent(new Action<InputStream>() { public void execute(InputStream inputStream) { URL schemaURL = validate ? getSchemaURL() : null; InputSource inSrc = new InputSource(inputStream); inSrc.setSystemId(descriptorURL.toExternalForm()); try { XMLHelper.parse(inSrc, schemaURL, Parser.this, null); } catch (Exception e) { throw new MetaDataParseException("Ivy file", getResource(), e); } } }); checkErrors(); checkConfigurations(); replaceConfigurationWildcards(); getMd().setModuleArtifact(DefaultArtifact.newIvyArtifact(getMd().getResolvedModuleRevisionId(), getMd().getPublicationDate())); if (!artifactsDeclared) { String[] configurationNames = getMd().getConfigurationsNames(); for (String configurationName : configurationNames) { getMd().addArtifact(configurationName, new MDArtifact(getMd(), getMd().getModuleRevisionId().getName(), "jar", "jar")); } } checkErrors(); getMd().check(); }
Example #2
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 6 votes |
protected static void printConfiguration(Configuration conf, PrintWriter out) { out.print("<conf"); out.print(" name=\"" + XMLHelper.escape(conf.getName()) + "\""); out.print(" visibility=\"" + XMLHelper.escape(conf.getVisibility().toString()) + "\""); if (conf.getDescription() != null) { out.print(" description=\"" + XMLHelper.escape(conf.getDescription()) + "\""); } String[] exts = conf.getExtends(); if (exts.length > 0) { out.print(listToPrefixedString(exts, " extends=\"")); } if (!conf.isTransitive()) { out.print(" transitive=\"false\""); } if (conf.getDeprecated() != null) { out.print(" deprecated=\"" + XMLHelper.escape(conf.getDeprecated()) + "\""); } printExtraAttributes(conf, out, " "); out.println("/>"); }
Example #3
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 6 votes |
private static void printDependencyArtefacts(ModuleDescriptor md, PrintWriter out, DependencyArtifactDescriptor[] depArtifacts) { if (depArtifacts.length > 0) { for (DependencyArtifactDescriptor depArtifact : depArtifacts) { out.print(String.format("\t\t\t<artifact name=\"%s\" type=\"%s\" ext=\"%s\"", XMLHelper.escape(depArtifact.getName()), XMLHelper.escape(depArtifact.getType()), XMLHelper.escape(depArtifact.getExt()))); final String[] dadConfs = depArtifact.getConfigurations(); if (dadConfs != null && dadConfs.length > 0) { if (!Arrays.asList(dadConfs).equals(Arrays.asList(md.getConfigurationsNames()))) { out.print(listToPrefixedString(dadConfs, " conf=\"")); } } printExtraAttributes(depArtifact, out, " "); out.println("/>"); } } }
Example #4
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 6 votes |
private static void printDependencyIncludeRules(ModuleDescriptor md, PrintWriter out, IncludeRule[] includes) { if (includes.length > 0) { for (IncludeRule include : includes) { out.print(String.format("\t\t\t<include name=\"%s\" type=\"%s\" ext=\"%s\"", XMLHelper.escape(include.getId().getName()), XMLHelper.escape(include.getId().getType()), XMLHelper.escape(include.getId().getExt()))); String[] ruleConfs = include.getConfigurations(); if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) { out.print(listToPrefixedString(ruleConfs, " conf=\"")); } out.print(" matcher=\"" + XMLHelper.escape(include.getMatcher().getName()) + "\""); out.println("/>"); } } }
Example #5
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 6 votes |
private static void printDependencyExcludeRules(ModuleDescriptor md, PrintWriter out, ExcludeRule[] excludes) { if (excludes.length > 0) { for (ExcludeRule exclude : excludes) { out.print(String.format("\t\t\t<exclude org=\"%s\" module=\"%s\" name=\"%s\" type=\"%s\" ext=\"%s\"", XMLHelper.escape(exclude.getId().getModuleId().getOrganisation()), XMLHelper.escape(exclude.getId().getModuleId().getName()), XMLHelper.escape(exclude.getId().getName()), XMLHelper.escape(exclude.getId().getType()), XMLHelper.escape(exclude.getId().getExt()))); String[] ruleConfs = exclude.getConfigurations(); if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) { out.print(listToPrefixedString(ruleConfs, " conf=\"")); } out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName()) + "\""); out.println("/>"); } } }
Example #6
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 6 votes |
private static void printAllExcludes(ModuleDescriptor md, PrintWriter out) { ExcludeRule[] excludes = md.getAllExcludeRules(); if (excludes.length > 0) { for (ExcludeRule exclude : excludes) { out.print(String.format("\t\t<exclude org=\"%s\" module=\"%s\" artifact=\"%s\" type=\"%s\" ext=\"%s\"", XMLHelper.escape(exclude.getId().getModuleId().getOrganisation()), XMLHelper.escape(exclude.getId().getModuleId().getName()), XMLHelper.escape(exclude.getId().getName()), XMLHelper.escape(exclude.getId().getType()), XMLHelper.escape(exclude.getId().getExt()))); String[] ruleConfs = exclude.getConfigurations(); if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) { out.print(listToPrefixedString(ruleConfs, " conf=\"")); } out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName()) + "\""); out.println("/>"); } } }
Example #7
Source File: XmlModuleDescriptorUpdater.java From ant-ivy with Apache License 2.0 | 6 votes |
public void characters(char[] ch, int start, int length) throws SAXException { if (justOpen != null) { write(">"); justOpen = null; } write(XMLHelper.escape(String.valueOf(ch, start, length))); // examine characters for current indent level, keeping in mind // that our indent might be split across multiple calls to characters() for (int i = start, end = start + length; i < end; ++i) { char c = ch[i]; if (c == '\r' || c == '\n') { // newline resets the indent level currentIndent.setLength(0); indenting = true; } else if (indenting) { // indent continues until first non-whitespace character if (Character.isWhitespace(c)) { currentIndent.append(c); } else { endIndent(); } } } }
Example #8
Source File: XmlModuleDescriptorUpdater.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * If no info/description element has yet been written, write the description inherited from * the parent descriptor, if any. Calling this method more than once has no affect. */ private void writeInheritedDescription(ModuleDescriptor merged) { if (!hasDescription) { hasDescription = true; String description = merged.getDescription(); if (!isNullOrEmpty(description)) { PrintWriter writer = getWriter(); if (justOpen != null) { writer.println(">"); } writeInheritanceComment("description", "parent"); writer.println(getIndent() + "<description>" + XMLHelper.escape(description) + "</description>"); // restore the indent that existed before we wrote the extra elements writer.print(currentIndent); justOpen = null; } } }
Example #9
Source File: XmlModuleDescriptorUpdater.java From ant-ivy with Apache License 2.0 | 6 votes |
public static void update(URL inStreamCtx, InputStream inStream, OutputStream outStream, final UpdateOptions options) throws IOException, SAXException { final PrintWriter out = new PrintWriter(new OutputStreamWriter(outStream, StandardCharsets.UTF_8)); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); out.write(LINE_SEPARATOR); try { UpdaterHandler updaterHandler = new UpdaterHandler(inStreamCtx, out, options); InputSource inSrc = new InputSource(new BufferedInputStream(inStream)); if (inStreamCtx != null) { inSrc.setSystemId(inStreamCtx.toExternalForm()); } XMLHelper.parse(inSrc, null, updaterHandler, updaterHandler); } catch (ParserConfigurationException e) { throw new IllegalStateException("impossible to update Ivy files: parser problem", e); } }
Example #10
Source File: MavenMetadataLoader.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void parseMavenMetadataInto(ExternalResource metadataResource, final MavenMetadata mavenMetadata) throws IOException, SAXException, ParserConfigurationException { LOGGER.debug("parsing maven-metadata: {}", metadataResource); metadataResource.withContent(new ErroringAction<InputStream>() { public void doExecute(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { XMLHelper.parse(inputStream, null, new ContextualSAXHandler() { public void endElement(String uri, String localName, String qName) throws SAXException { if ("metadata/versioning/snapshot/timestamp".equals(getContext())) { mavenMetadata.timestamp = getText(); } if ("metadata/versioning/snapshot/buildNumber".equals(getContext())) { mavenMetadata.buildNumber = getText(); } if ("metadata/versioning/versions/version".equals(getContext())) { mavenMetadata.versions.add(getText().trim()); } super.endElement(uri, localName, qName); } }, null); } }); }
Example #11
Source File: IvyXmlModuleDescriptorParser.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void parse() throws ParseException, IOException { getResource().withContent(new Action<InputStream>() { public void execute(InputStream inputStream) { URL schemaURL = validate ? getSchemaURL() : null; InputSource inSrc = new InputSource(inputStream); inSrc.setSystemId(descriptorURL.toExternalForm()); try { XMLHelper.parse(inSrc, schemaURL, Parser.this, null); } catch (Exception e) { throw new MetaDataParseException("Ivy file", getResource(), e); } } }); checkErrors(); checkConfigurations(); replaceConfigurationWildcards(); getMd().setModuleArtifact(DefaultArtifact.newIvyArtifact(getMd().getResolvedModuleRevisionId(), getMd().getPublicationDate())); if (!artifactsDeclared) { String[] configurationNames = getMd().getConfigurationsNames(); for (String configurationName : configurationNames) { getMd().addArtifact(configurationName, new MDArtifact(getMd(), getMd().getModuleRevisionId().getName(), "jar", "jar")); } } checkErrors(); getMd().check(); }
Example #12
Source File: MavenMetadataLoader.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void parseMavenMetadataInto(ExternalResource metadataResource, final MavenMetadata mavenMetadata) throws IOException, SAXException, ParserConfigurationException { LOGGER.debug("parsing maven-metadata: {}", metadataResource); metadataResource.withContent(new ErroringAction<InputStream>() { public void doExecute(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { XMLHelper.parse(inputStream, null, new ContextualSAXHandler() { public void endElement(String uri, String localName, String qName) throws SAXException { if ("metadata/versioning/snapshot/timestamp".equals(getContext())) { mavenMetadata.timestamp = getText(); } if ("metadata/versioning/snapshot/buildNumber".equals(getContext())) { mavenMetadata.buildNumber = getText(); } if ("metadata/versioning/versions/version".equals(getContext())) { mavenMetadata.versions.add(getText().trim()); } super.endElement(uri, localName, qName); } }, null); } }); }
Example #13
Source File: MavenMetadataLoader.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void parseMavenMetadataInto(ExternalResource metadataResource, final MavenMetadata mavenMetadata) throws IOException, SAXException, ParserConfigurationException { LOGGER.debug("parsing maven-metadata: {}", metadataResource); metadataResource.withContent(new ErroringAction<InputStream>() { public void doExecute(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { XMLHelper.parse(inputStream, null, new ContextualSAXHandler() { public void endElement(String uri, String localName, String qName) throws SAXException { if ("metadata/versioning/snapshot/timestamp".equals(getContext())) { mavenMetadata.timestamp = getText(); } if ("metadata/versioning/snapshot/buildNumber".equals(getContext())) { mavenMetadata.buildNumber = getText(); } if ("metadata/versioning/versions/version".equals(getContext())) { mavenMetadata.versions.add(getText().trim()); } super.endElement(uri, localName, qName); } }, null); } }); }
Example #14
Source File: MavenMetadataLoader.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void parseMavenMetadataInto(ExternalResource metadataResource, final MavenMetadata mavenMetadata) throws IOException, SAXException, ParserConfigurationException { LOGGER.debug("parsing maven-metadata: {}", metadataResource); metadataResource.withContent(new ErroringAction<InputStream>() { public void doExecute(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { XMLHelper.parse(inputStream, null, new ContextualSAXHandler() { public void endElement(String uri, String localName, String qName) throws SAXException { if ("metadata/versioning/snapshot/timestamp".equals(getContext())) { mavenMetadata.timestamp = getText(); } if ("metadata/versioning/snapshot/buildNumber".equals(getContext())) { mavenMetadata.buildNumber = getText(); } if ("metadata/versioning/versions/version".equals(getContext())) { mavenMetadata.versions.add(getText().trim()); } super.endElement(uri, localName, qName); } }, null); } }); }
Example #15
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputArtifacts(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) { out.println("\t\t\t\t<artifacts>"); for (ArtifactDownloadReport adr : report.getDownloadReports(dep.getResolvedId())) { out.print("\t\t\t\t\t<artifact name=\"" + XMLHelper.escape(adr.getName()) + "\" type=\"" + XMLHelper.escape(adr.getType()) + "\" ext=\"" + XMLHelper.escape(adr.getExt()) + "\""); out.print(extraToString(adr.getArtifact().getQualifiedExtraAttributes(), SEPARATOR)); out.print(" status=\"" + XMLHelper.escape(adr.getDownloadStatus().toString()) + "\""); out.print(" details=\"" + XMLHelper.escape(adr.getDownloadDetails()) + "\""); out.print(" size=\"" + adr.getSize() + "\""); out.print(" time=\"" + adr.getDownloadTimeMillis() + "\""); if (adr.getLocalFile() != null) { out.print(" location=\"" + XMLHelper.escape(adr.getLocalFile().getAbsolutePath()) + "\""); } if (adr.getUnpackedLocalFile() != null) { out.print(" unpackedFile=\"" + XMLHelper.escape(adr.getUnpackedLocalFile().getAbsolutePath()) + "\""); } ArtifactOrigin origin = adr.getArtifactOrigin(); if (origin != null) { out.println(">"); out.println("\t\t\t\t\t\t<origin-location is-local=\"" + String.valueOf(origin.isLocal()) + "\"" + " location=\"" + XMLHelper.escape(origin.getLocation()) + "\"/>"); out.println("\t\t\t\t\t</artifact>"); } else { out.println("/>"); } } out.println("\t\t\t\t</artifacts>"); }
Example #16
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputCallers(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) { for (Caller caller : dep.getCallers(report.getConfiguration())) { final DependencyDescriptor dependencyDescriptor = caller.getDependencyDescriptor(); out.println(String.format("\t\t\t\t<caller organisation=\"%s\" name=\"%s\" conf=\"%s\" rev=\"%s\" rev-constraint-default=\"%s\" rev-constraint-dynamic=\"%s\" callerrev=\"%s\"%s/>", XMLHelper.escape(caller.getModuleRevisionId().getOrganisation()), XMLHelper.escape(caller.getModuleRevisionId().getName()), XMLHelper.escape(joinArray(caller.getCallerConfigurations(), ", ")), XMLHelper.escape(caller.getAskedDependencyId().getRevision()), XMLHelper.escape(dependencyDescriptor.getDependencyRevisionId().getRevision()), XMLHelper.escape(dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision()), XMLHelper.escape(caller.getModuleRevisionId().getRevision()), extraToString(dependencyDescriptor.getQualifiedExtraAttributes(), SEPARATOR))); } }
Example #17
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputMetadataArtifact(PrintWriter out, IvyNode dep) { if (dep.getModuleRevision() != null) { MetadataArtifactDownloadReport madr = dep.getModuleRevision().getReport(); out.print("\t\t\t\t<metadata-artifact"); out.print(" status=\"" + XMLHelper.escape(madr.getDownloadStatus().toString()) + "\""); out.print(" details=\"" + XMLHelper.escape(madr.getDownloadDetails()) + "\""); out.print(" size=\"" + madr.getSize() + "\""); out.print(" time=\"" + madr.getDownloadTimeMillis() + "\""); if (madr.getLocalFile() != null) { out.print(" location=\"" + XMLHelper.escape(madr.getLocalFile().getAbsolutePath()) + "\""); } out.print(" searched=\"" + madr.isSearched() + "\""); if (madr.getOriginalLocalFile() != null) { out.print(" original-local-location=\"" + XMLHelper.escape(madr.getOriginalLocalFile().getAbsolutePath()) + "\""); } ArtifactOrigin origin = madr.getArtifactOrigin(); if (origin != null) { out.print(" origin-is-local=\"" + String.valueOf(origin.isLocal()) + "\""); out.print(" origin-location=\"" + XMLHelper.escape(origin.getLocation()) + "\""); } out.println("/>"); } }
Example #18
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputEvictionInformation(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) { if (dep.isEvicted(report.getConfiguration())) { EvictionData ed = dep.getEvictedData(report.getConfiguration()); Collection<IvyNode> selected = ed.getSelected(); if (selected != null) { for (IvyNode sel : selected) { out.println("\t\t\t\t<evicted-by rev=\"" + XMLHelper.escape(sel.getResolvedId().getRevision()) + "\"/>"); } } } }
Example #19
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private String extraToString(Map<String, String> extraAttributes, String prefix) { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : extraAttributes.entrySet()) { if (sb.length() > 0 && !SEPARATOR.equals(prefix)) { sb.append(System.lineSeparator()); } sb.append(prefix); sb.append(ExtendableItemHelper.encodeAttribute(entry.getKey(), "extra-")); sb.append("=\""); sb.append(XMLHelper.escape(entry.getValue())); sb.append("\""); } return sb.toString(); }
Example #20
Source File: XmlModuleDescriptorParserTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testBad() throws IOException, ParseException { expExc.expect(ParseException.class); expExc.expectMessage("'modul'"); assertTrue(XMLHelper.canUseSchemaValidation()); XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-bad.xml"), true); }
Example #21
Source File: XmlModuleDescriptorParserTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testBadOrg() throws IOException, ParseException { expExc.expect(ParseException.class); expExc.expectMessage("organization"); assertTrue(XMLHelper.canUseSchemaValidation()); XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-bad-org.xml"), true); }
Example #22
Source File: XmlModuleDescriptorParser.java From ant-ivy with Apache License 2.0 | 5 votes |
protected void includeConfStarted(Attributes attributes) throws SAXException, IOException, ParserConfigurationException, ParseException { URL url = settings.getRelativeUrlResolver().getURL(descriptorURL, settings.substitute(attributes.getValue("file")), settings.substitute(attributes.getValue("url"))); if (url == null) { throw new SAXException("include tag must have a file or an url attribute"); } // create a new temporary parser to read the configurations from // the specified file. Parser parser = new Parser(getModuleDescriptorParser(), settings); parser.setInput(url); parser.setMd(new DefaultModuleDescriptor(getModuleDescriptorParser(), new URLResource(url))); XMLHelper.parse(url, null, parser); // add the configurations from this temporary parser to this module descriptor for (Configuration config : parser.getModuleDescriptor().getConfigurations()) { getMd().addConfiguration(config); } if (parser.getDefaultConfMapping() != null) { Message.debug("setting default conf mapping from imported configurations file: " + parser.getDefaultConfMapping()); setDefaultConfMapping(parser.getDefaultConfMapping()); } if (parser.getDefaultConf() != null) { Message.debug("setting default conf from imported configurations file: " + parser.getDefaultConf()); setDefaultConf(parser.getDefaultConf()); } if (parser.getMd().isMappingOverride()) { Message.debug("enabling mapping-override from imported configurations" + " file"); getMd().setMappingOverride(true); } }
Example #23
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private static void printExtraInfoElement(PrintWriter out, ExtraInfoHolder extraInfo, int indent) { for (int i = 1; i <= indent; i++) { out.print("\t"); } out.print("<"); out.print(extraInfo.getName()); for (Map.Entry<String, String> entry : extraInfo.getAttributes().entrySet()) { out.print(String.format(" %s=\"%s\"", entry.getKey(), entry.getValue())); } boolean requireClosingTag = false; if (!isNullOrEmpty(extraInfo.getContent())) { out.print(">"); out.print(XMLHelper.escape(extraInfo.getContent())); requireClosingTag = true; } if (!extraInfo.getNestedExtraInfoHolder().isEmpty()) { out.println(">"); for (ExtraInfoHolder nestedElement : extraInfo.getNestedExtraInfoHolder()) { printExtraInfoElement(out, nestedElement, indent + 1); } requireClosingTag = true; // prepare indentation for closing tag for (int i = 1; i <= indent; i++) { out.print("\t"); } } if (requireClosingTag) { out.print("</"); out.print(extraInfo.getName()); out.println(">"); } else { out.println("/>"); } }
Example #24
Source File: XmlReportWriterTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testWriteOrigin() throws Exception { ResolveReport report = ivy.resolve(new File( "test/repositories/1/special-encoding-root-ivy.xml"), getResolveOptions(new String[] {"default"})); assertNotNull(report); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); XmlReportWriter writer = new XmlReportWriter(); writer.output(report.getConfigurationReport("default"), buffer); buffer.flush(); String xml = buffer.toString(XmlReportWriter.REPORT_ENCODING); String expectedLocation = "location=\"" + new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").getAbsolutePath() + "\""; String expectedIsLocal = "is-local=\"true\""; String expectedOrg = "organisation=\"sp\u00E9cial\""; assertTrue("XML doesn't contain artifact location attribute", xml.contains(expectedLocation)); assertTrue("XML doesn't contain artifact is-local attribute", xml.contains(expectedIsLocal)); assertTrue("XML doesn't contain the organisation", xml.contains(expectedOrg)); // check that the XML is valid XMLHelper.parse(new ByteArrayInputStream(buffer.toByteArray()), null, new DefaultHandler(), null); }
Example #25
Source File: XmlModuleDescriptorWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Writes the specified <tt>Map</tt> containing the extra attributes to the given * <tt>PrintWriter</tt>. * * @param extra * the extra attributes, can be <tt>null</tt> * @param out * the writer to use * @param prefix * the string to write before writing the attributes (if any) */ private static void printExtraAttributes(Map<String, String> extra, PrintWriter out, String prefix) { if (extra == null) { return; } String delim = prefix; for (Map.Entry<String, String> entry : extra.entrySet()) { out.print(String.format("%s%s=\"%s\"", delim, entry.getKey(), XMLHelper.escape(entry.getValue()))); delim = " "; } }
Example #26
Source File: IvyXmlModuleDescriptorParser.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void includeConfStarted(Attributes attributes) throws SAXException, IOException, ParserConfigurationException, ParseException { URL url = relativeUrlResolver.getURL(descriptorURL, substitute(attributes.getValue("file")), substitute(attributes.getValue("url"))); if (url == null) { throw new SAXException("include tag must have a file or an url attribute"); } // create a new temporary parser to read the configurations from // the specified file. Parser parser = newParser(new UrlExternalResource(url), url); XMLHelper.parse(url , null, parser); // add the configurations from this temporary parser to this module descriptor Configuration[] configs = parser.getModuleDescriptor().getConfigurations(); for (Configuration config : configs) { getMd().addConfiguration(config); } if (parser.getDefaultConfMapping() != null) { LOGGER.debug("setting default conf mapping from imported configurations file: " + parser.getDefaultConfMapping()); setDefaultConfMapping(parser.getDefaultConfMapping()); } if (parser.getDefaultConf() != null) { LOGGER.debug("setting default conf from imported configurations file: " + parser.getDefaultConf()); setDefaultConf(parser.getDefaultConf()); } if (parser.getMd().isMappingOverride()) { LOGGER.debug("enabling mapping-override from imported configurations file"); getMd().setMappingOverride(true); } }
Example #27
Source File: IvyXmlModuleDescriptorParser.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void includeConfStarted(Attributes attributes) throws SAXException, IOException, ParserConfigurationException, ParseException { URL url = relativeUrlResolver.getURL(descriptorURL, substitute(attributes.getValue("file")), substitute(attributes.getValue("url"))); if (url == null) { throw new SAXException("include tag must have a file or an url attribute"); } // create a new temporary parser to read the configurations from // the specified file. Parser parser = newParser(new UrlExternalResource(url), url); XMLHelper.parse(url , null, parser); // add the configurations from this temporary parser to this module descriptor Configuration[] configs = parser.getModuleDescriptor().getConfigurations(); for (Configuration config : configs) { getMd().addConfiguration(config); } if (parser.getDefaultConfMapping() != null) { LOGGER.debug("setting default conf mapping from imported configurations file: " + parser.getDefaultConfMapping()); setDefaultConfMapping(parser.getDefaultConfMapping()); } if (parser.getDefaultConf() != null) { LOGGER.debug("setting default conf from imported configurations file: " + parser.getDefaultConf()); setDefaultConf(parser.getDefaultConf()); } if (parser.getMd().isMappingOverride()) { LOGGER.debug("enabling mapping-override from imported configurations file"); getMd().setMappingOverride(true); } }
Example #28
Source File: P2MetadataParser.java From ant-ivy with Apache License 2.0 | 5 votes |
public void parse(InputStream in) throws IOException, ParseException, SAXException { RepositoryHandler handler = new RepositoryHandler(p2Descriptor); try { XMLHelper.parse(in, null, handler, null); } catch (ParserConfigurationException e) { throw new SAXException(e); } }
Example #29
Source File: P2CompositeParser.java From ant-ivy with Apache License 2.0 | 5 votes |
public void parse(InputStream in) throws IOException, ParseException, SAXException { RepositoryHandler handler = new RepositoryHandler(); try { XMLHelper.parse(in, null, handler, null); } catch (ParserConfigurationException e) { throw new SAXException(e); } childLocations.addAll(handler.childLocations); }
Example #30
Source File: P2ArtifactParser.java From ant-ivy with Apache License 2.0 | 5 votes |
public void parse(InputStream in) throws IOException, ParseException, SAXException { RepositoryHandler handler = new RepositoryHandler(p2Descriptor, repoUrl); try { XMLHelper.parse(in, null, handler, null); } catch (ParserConfigurationException e) { throw new SAXException(e); } }