public static Literal parseLiteral(String nTriplesLiteral,ValueFactory valueFactory) throws IllegalArgumentException {
  if (nTriplesLiteral.startsWith("\"")) {
    int endLabelIdx=findEndOfLabel(nTriplesLiteral);
    if (endLabelIdx != -1) {
      int startLangIdx=nTriplesLiteral.indexOf("@",endLabelIdx);
      int startDtIdx=nTriplesLiteral.indexOf("^^",endLabelIdx);
      if (startLangIdx != -1 && startDtIdx != -1) {
        throw new IllegalArgumentException("Literals can not have both a language and a datatype");
      }
      String label=nTriplesLiteral.substring(1,endLabelIdx);
      label=unescapeString(label);
      if (startLangIdx != -1) {
        String language=nTriplesLiteral.substring(startLangIdx + 1);
        return valueFactory.createLiteral(label,language);
      }
 else       if (startDtIdx != -1) {
        String datatype=nTriplesLiteral.substring(startDtIdx + 2);
        IRI dtURI=parseURI(datatype,valueFactory);
        return valueFactory.createLiteral(label,dtURI);
      }
 else {
        return valueFactory.createLiteral(label);
      }
    }
  }
  throw new IllegalArgumentException("Not a legal N-Triples literal: " + nTriplesLiteral);
}

public static Literal parseLiteral ( String nTriplesLiteral , ValueFactory valueFactory ) throws IllegalArgumentException { if ( nTriplesLiteral . startsWith ( "\"" ) ) { int endLabelIdx = findEndOfLabel ( nTriplesLiteral ) ; if ( endLabelIdx != - 1 ) { int startLangIdx = nTriplesLiteral . indexOf ( "@" , endLabelIdx ) ; int startDtIdx = nTriplesLiteral . indexOf ( "^^" , endLabelIdx ) ; if ( startLangIdx != - 1 && startDtIdx != - 1 ) { throw new IllegalArgumentException ( "Literals can not have both a language and a datatype" ) ; } String label = nTriplesLiteral . substring ( 1 , endLabelIdx ) ; label = unescapeString ( label ) ; if ( startLangIdx != - 1 ) { String language = nTriplesLiteral . substring ( startLangIdx + 1 ) ; return valueFactory . createLiteral ( label , language ) ; } else if ( startDtIdx != - 1 ) { String datatype = nTriplesLiteral . substring ( startDtIdx + 2 ) ; IRI dtURI = parseURI ( datatype , valueFactory ) ; return valueFactory . createLiteral ( label , dtURI ) ; } else { return valueFactory . createLiteral ( label ) ; } } } throw new IllegalArgumentException ( "Not a legal N-Triples literal: " + nTriplesLiteral ) ; }
parses an n - triples literal , creates an object for it using the supplied valuefactory and returns this object .
