Iterator<Triple> startPosIterator = enhancements.filter(textAnnotation,
ENHANCER_START, null);
Iterator<Triple> endPosIterator = enhancements.filter(textAnnotation,
ENHANCER_END, null);
//start end is optional, but if start is present, that also end needs to be set
TypedLiteral startPosLiteral;
TypedLiteral endPosLiteral;
if(startPosIterator.hasNext()){
//NOTE: TextAnnotations might be use to select whole sections of a text
// (e.g. see STANBOL-617) in those cases adding the text of the
// whole section is not feasible.
//assertNotNull("If fise:start is present the fise:selection-context MUST also be present (uri: "+textAnnotation+")!",
// selectionContextResource);
Resource resource = startPosIterator.next().getObject();
//only a single start position is supported
assertFalse("fise:start MUST HAVE only a single value (uri: "+textAnnotation+")!",startPosIterator.hasNext());
assertTrue("fise:start MUST be a typed Literal (uri: "+textAnnotation+")!",resource instanceof TypedLiteral);
startPosLiteral = (TypedLiteral) resource;
assertEquals("fise:start MUST use xsd:int as data type (uri: "+textAnnotation+")",XSD.int_, startPosLiteral.getDataType());
resource = null;
Integer start = LiteralFactory.getInstance().createObject(Integer.class, startPosLiteral);
assertNotNull("Unable to parse Integer from TypedLiteral "+startPosLiteral,start);
//now get the end
//end must be defined if start is present
assertTrue("If fise:start is present also fise:end MUST BE defined (uri: "+textAnnotation+")!",endPosIterator.hasNext());
resource = endPosIterator.next().getObject();
//only a single end position is supported
assertFalse("fise:end MUST HAVE only a single value (uri: "+textAnnotation+")!",endPosIterator.hasNext());
assertTrue("fise:end values MUST BE TypedLiterals (uri: "+textAnnotation+")",resource instanceof TypedLiteral);
endPosLiteral = (TypedLiteral) resource;
assertEquals("fise:end MUST use xsd:int as data type (uri: "+textAnnotation+")",XSD.int_, endPosLiteral.getDataType());
resource = null;
Integer end = LiteralFactory.getInstance().createObject(Integer.class, endPosLiteral);
assertNotNull("Unable to parse Integer from TypedLiteral "+endPosLiteral,end);
//check for equality of the selected text and the text on the selected position in the content
//System.out.println("TA ["+start+"|"+end+"]"+selectedText.getLexicalForm()+"<->"+content.substring(start,end));