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

protected Literal parseLiteral ( String literal ) throws IllegalArgumentException { if ( literal . startsWith ( "\"" ) ) { int endLabelIdx = findEndOfLabel ( literal ) ; if ( endLabelIdx != - 1 ) { int startLangIdx = literal . indexOf ( "@" , endLabelIdx ) ; int startDtIdx = literal . indexOf ( "^^" , endLabelIdx ) ; if ( startLangIdx != - 1 && startDtIdx != - 1 ) { throw new IllegalArgumentException ( "Literals can not have both a language and a datatype" ) ; } String label = literal . substring ( 1 , endLabelIdx ) ; label = decodeString ( label ) ; if ( startLangIdx != - 1 ) { String language = literal . substring ( startLangIdx + 1 ) ; return valueFactory . createLiteral ( label , language ) ; } else if ( startDtIdx != - 1 ) { String datatype = literal . substring ( startDtIdx + 2 ) ; datatype = datatype . substring ( 1 , datatype . length ( ) - 1 ) ; IRI dtURI = valueFactory . createIRI ( datatype ) ; return valueFactory . createLiteral ( label , dtURI ) ; } else { return valueFactory . createLiteral ( label ) ; } } } throw new IllegalArgumentException ( "Not a legal literal: " + literal ) ; }
parses a literal , creates an object for it and returns this object .
