org.apache.ivy.util.ContextualSAXHandler Java Examples
The following examples show how to use
org.apache.ivy.util.ContextualSAXHandler.
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: 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 #2
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 #3
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 #4
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 #5
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
private String findTimestampedSnapshotVersion(final ModuleRevisionId mrid) { if (!isM2compatible()) { return null; } if (!shouldUseMavenMetadata(getWholePattern())) { return null; } try { final String metadataLocation = IvyPatternHelper.substitute(root + "[organisation]/[module]/[revision]/maven-metadata.xml", mrid); final Resource metadata = getRepository().getResource(metadataLocation); if (!metadata.exists()) { Message.verbose("\tmaven-metadata not available for: " + mrid); return null; } try (final InputStream metadataStream = metadata.openStream()) { final StringBuilder timestamp = new StringBuilder(); final StringBuilder buildNumber = new StringBuilder(); XMLHelper.parse(metadataStream, null, new ContextualSAXHandler() { @Override public void endElement(String uri, String localName, String qName) throws SAXException { if ("metadata/versioning/snapshot/timestamp".equals(getContext())) { timestamp.append(getText()); } if ("metadata/versioning/snapshot/buildNumber".equals(getContext())) { buildNumber.append(getText()); } super.endElement(uri, localName, qName); } }, null); if (timestamp.length() > 0) { // we have found a timestamp, so this is a snapshot unique version String rev = mrid.getRevision(); rev = rev.substring(0, rev.length() - "SNAPSHOT".length()); rev += timestamp.toString() + "-" + buildNumber.toString(); return rev; } } } catch (IOException | SAXException | ParserConfigurationException e) { Message.debug("impossible to access maven metadata file, ignored", e); } return null; }