xpath-helper

XPath helpers based on Xom

License

License

GroupId

GroupId

com.itelg
ArtifactId

ArtifactId

xpath-helper
Last Version

Last Version

0.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

xpath-helper
XPath helpers based on Xom
Project URL

Project URL

https://github.com/julian-eggers/xpath-helper
Source Code Management

Source Code Management

https://github.com/julian-eggers/xpath-helper

Download xpath-helper

How to add to project

<!-- https://jarcasting.com/artifacts/com.itelg/xpath-helper/ -->
<dependency>
    <groupId>com.itelg</groupId>
    <artifactId>xpath-helper</artifactId>
    <version>0.6.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.itelg/xpath-helper/
implementation 'com.itelg:xpath-helper:0.6.0'
// https://jarcasting.com/artifacts/com.itelg/xpath-helper/
implementation ("com.itelg:xpath-helper:0.6.0")
'com.itelg:xpath-helper:jar:0.6.0'
<dependency org="com.itelg" name="xpath-helper" rev="0.6.0">
  <artifact name="xpath-helper" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.itelg', module='xpath-helper', version='0.6.0')
)
libraryDependencies += "com.itelg" % "xpath-helper" % "0.6.0"
[com.itelg/xpath-helper "0.6.0"]

Dependencies

compile (2)

Group / Artifact Type Version
xom : xom jar 1.3.4
org.apache.commons : commons-lang3 jar 3.10

provided (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.30

test (8)

Group / Artifact Type Version
org.assertj : assertj-core jar 3.15.0
org.easymock : easymock jar 4.2
org.powermock : powermock-module-junit4 jar 2.0.5
org.powermock : powermock-api-easymock jar 2.0.5
org.jacoco : org.jacoco.agent jar 0.8.5
org.junit.jupiter : junit-jupiter-engine jar 5.6.2
org.junit.vintage : junit-vintage-engine jar 5.6.2
commons-io : commons-io jar 2.6

Project Modules

There are no modules declared in this project.

xpath-helper

Maven Central Codacy Badge Coverage Status Build Status

XPath helpers based on XOM

Maven

<dependency>
	<groupId>com.itelg</groupId>
	<artifactId>xpath-helper</artifactId>
	<version>0.6.0</version>
</dependency>

Supported methods

getNodes() : Nodes
getNodeList() : List<Node>
hasNodes() : boolean
hasNode() : boolean
getFirstNode() : Node
getFirstElement() : Element
getLastNode() : Node
getLastElement() : Element
getString() : String
getNullableString() : String
getDouble() : Double
getPDouble() : double
getInteger() : Integer
getInt() : int
getLong() : Long
getPLong() : long
getBoolean() : Boolean
getBool() : boolean
getZonedDateTime() : ZonedDateTime
getLocalDateTime() : LocalDateTime
getLocalDate() : LocalDate
getEnum() : Enum<E>

AbstractParser-Example

public static void main(String[] args) throws Exception
{
	String xml = "<data><stringValue>Test</stringValue>"
			+ "<doubleValue>1.12</doubleValue>"
			+ "<testEnum>VALUE</testEnum></data>";
	TestClass testClass = new TestParser().parse(xml);
	System.out.println(testClass);
}

public static class TestParser extends AbstractParser<TestClass>
{
	@Override
	protected TestClass doParse(Element rootElement) throws Exception
	{
		TestClass test = new TestClass();
		test.stringValue = XPathHelper.getString("stringValue", rootElement);
		test.doubleValue = XPathHelper.getDouble("doubleValue", rootElement);
		test.testEnum = XPathHelper.getEnum("testEnum", TestClass.TestEnum.class, rootElement);
		return test;
	}
}

public static class TestClass
{
	private String stringValue;
	private Double doubleValue;
	private TestEnum testEnum;
	
	@Override
	public String toString()
	{
		return "TestClass [stringValue=" + stringValue + ", doubleValue=" + doubleValue + ", testEnum=" + testEnum + "]";
	}

	private enum TestEnum
	{
		VALUE;
	}
}

Plain-Example

public static void main(String[] args) throws Exception
{
	String xml = "<data><stringValue>Test</stringValue>"
			+ "<doubleValue>1.12</doubleValue></data>";
	Element rootElement = DocumentHelper.getRootElement(xml);
	System.out.println(XPathHelper.getString("stringValue", rootElement));
	System.out.println(XPathHelper.getDouble("doubleValue", rootElement));
}

Build & Release

Build

mvn clean package

Release

mvn clean deploy

Versions

Version
0.6.0
0.6.0-RC1
0.5.3-RELEASE
0.5.2-RELEASE
0.5.1-RELEASE
0.5.0-RELEASE
0.4.7-RELEASE
0.4.6-RELEASE
0.4.5-RELEASE
0.4.4-RELEASE
0.4.3-RELEASE
0.4.2-RELEASE
0.4.1-RELEASE
0.4.0-RELEASE
0.3.0-RELEASE