forked from objectionary/jeo-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(objectionary#112): save class atributes to EO object attributes
- Loading branch information
1 parent
47aaaa8
commit a9dc6dc
Showing
9 changed files
with
91 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/org/eolang/jeo/representation/asm/HexString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.eolang.jeo.representation.asm; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public class HexString { | ||
|
||
private final String hex; | ||
|
||
public HexString(final String hex) { | ||
this.hex = hex; | ||
} | ||
|
||
/** | ||
* Convert hex string to human-readable string. | ||
* Example: | ||
* "48 65 6C 6C 6F 20 57 6F 72 6C 64 21" -> "Hello World!" | ||
* @return Human-readable string. | ||
*/ | ||
String decode() { | ||
return Arrays.stream(hex.split(" ")) | ||
.map(ch -> (char) Integer.parseInt(ch, 16)) | ||
.map(String::valueOf) | ||
.collect(Collectors.joining()); | ||
} | ||
|
||
int decodeAsInt() { | ||
return Arrays.stream(this.hex.split(" ")) | ||
.mapToInt(ch -> Integer.parseInt(ch, 16)) | ||
.sum(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/org/eolang/jeo/representation/asm/XmlClassProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.eolang.jeo.representation.asm; | ||
|
||
import com.jcabi.xml.XMLDocument; | ||
import org.w3c.dom.Node; | ||
|
||
public class XmlClassProperties { | ||
private final XMLDocument clazz; | ||
|
||
public XmlClassProperties(final Node clazz) { | ||
this.clazz = new XMLDocument(clazz); | ||
} | ||
|
||
public int access() { | ||
return new HexString(this.clazz.xpath("//o[@name='access']/text()").get(0)).decodeAsInt(); | ||
} | ||
|
||
public String signature() { | ||
return this.clazz.xpath("//o[@name='signature']/text()").get(0); | ||
} | ||
|
||
public String supername() { | ||
return this.clazz.xpath("//o[@name='supername']/text()").get(0); | ||
|
||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters