Skip to content

Commit

Permalink
Added simple data API for ImageLetters. Updated to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RubbaBoy committed Nov 6, 2018
1 parent c61c7b4 commit 9f3349c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ NewOCR is on Central, so it's insanely easy to get on both Maven and Gradle.

Gradle:
```Groovy
compile 'com.uddernetworks.newocr:NewOCR:1.0.0'
compile 'com.uddernetworks.newocr:NewOCR:1.0.1'
```

Maven:
```XML
<dependency>
<groupId>com.uddernetworks.newocr</groupId>
<artifactId>NewOCR</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply plugin: 'io.codearte.nexus-staging'

group 'com.uddernetworks.newocr'
archivesBaseName = "NewOCR"
version '1.0.0'
version '1.0.1'

sourceCompatibility = 1.8

Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/uddernetworks/newocr/ImageLetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ImageLetter {
private int height;
private double ratio;
private List<Map.Entry<Integer, Integer>> segments;
private Object data;

/**
* Creates an ImageLetter from collected data.
Expand Down Expand Up @@ -140,4 +141,31 @@ public List<Map.Entry<Integer, Integer>> getSegments() {
public char getLetter() {
return this.databaseCharacter.getLetter();
}

/**
* Gets any data set to the {@link ImageLetter} object, useful for storing any needed data about the character to be
* used in the future.
* @return Data set to the character
*/
public <T> T getData(Class<T> clazz) {
return clazz.isInstance(data) ? clazz.cast(data) : null;
}

/**
* Gets the raw data Object set to the {@link ImageLetter} object, useful for storing any needed data about the
* character to be used in the future.
* @return Data set to the character
*/
public Object getData() {
return this.data;
}

/**
* Sets any data to the {@link ImageLetter} object, useful for storing any needed data about the character to be
* used in the future.
* @param data The data to be set
*/
public void setData(Object data) {
this.data = data;
}
}

0 comments on commit 9f3349c

Please sign in to comment.