code: private String objectToString(Object obj, String xsdType) {
          if (obj == null) {
              return "null";
          }
          String javaType = obj.getClass().getCanonicalName();
          String term;
          if (javaType != null && javaType.equals("java.util.Date")) { // several circumstances yield null canonical names
              term = DateUtility.convertDateToXSDString((Date) obj);
          } else if (xsdType.equals("fedora-types:ArrayOfString")) {
              term = array2string(obj);
          } else if (xsdType.equals("xsd:boolean")) {
              term = obj.toString();
          } else if (xsdType.equals("xsd:nonNegativeInteger")) {
              term = obj.toString();
          } else if (xsdType.equals("fedora-types:RelationshipTuple")) {
              RelationshipTuple[] tuples = (RelationshipTuple[]) obj;
              TupleArrayTripleIterator iter =
                      new TupleArrayTripleIterator(new ArrayList<RelationshipTuple>(Arrays
                              .asList(tuples)));
              ReadableByteArrayOutputStream os = new ReadableByteArrayOutputStream();
              try {
                  iter.toStream(os, RDFFormat.NOTATION_3, false);
              } catch (TrippiException e) {
                  e.printStackTrace();
              }
              term = os.getString(Charset.forName("UTF-8"));
          } else if (javaType != null && javaType.equals("java.lang.String")) {
              term = (String) obj;
              term = term.replaceAll("\"", "'");
          } else {
              term = "[OMITTED]";
          }
          return term;
      }
docs: Get the String value of an object based on its class or
  XML Schema Datatype.
  
  @param obj
  @param xsdType
  @return