/** * Returns a particularly dumb implementation of a unique identifier */ public synchronized String getID(LSIDProvider.NamespaceEnumeration namespace) { return "urn:lsid:net.sf.taverna:" + namespace.toString() + ":" + (count++); }
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source * The data to convert * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
/** * @return the LSID of this result */ public String getLSID() { return thing.getLSID(thing.getDataObject()); }
public Map execute(Map inputs) throws TaskExecutionException { Map results = new HashMap(); byte[] bytes = (byte[]) ((DataThing) inputs.get("bytes")).getDataObject(); String base64 = Base64.encodeBytes(bytes); results.put("base64", new DataThing(base64)); return results; }
/** * For String arrays convert the array to a List and store that. */ public static DataThing bake(String[] theStringArray) { return new DataThing(convertObject(theStringArray)); /** * List theList = new ArrayList(); for (int i = 0; i < * theStringArray.length; i++) { theList.add(theStringArray[i]); } * return new DataThing(theList); */ }
/** * Extract a child object as a DataThing. This assumes that the object * referenced is actually within this DataThing object, behaviour is * undefined otherwise. Although we could check this and impose it as a * constraint the performance hit of traversing the entire original * DataThing collection structure and doing potentially expensive * equivalence computations is probably not worth it. Use with care. * * @return a view on an object contained within this DataThing as a new * DataThing */ public DataThing extractChild(Object child) { DataThing result = new DataThing(this); result.theDataObject = child; return result; }
public InputDataThingNode(Port port, DataThing thing) { super(thing.getDataObject()); this.port = port; this.thing = thing; this.mimeTypes = thing.getMetadata().getMIMETypeList(); }
public boolean canMakeFacets(DataThing dataThing) { return dataThing.getDataObject() instanceof CharSequence; }
/** * Set the underlying data object, this is the first level of the data * document. */ private void setDataObject(Object data) { theDataObject = data; setLSID(theDataObject, ""); doInternalLSIDFill(theDataObject, SYSTEM_DEFAULT_LSID_PROVIDER); }
/** * Encodes the first three bytes of array <var>threeBytes</var> and returns * a four-byte array in Base64 notation. * * @param threeBytes * the array to convert * @return four byte array in Base64 notation. * @since 1.3 */ private static byte[] encode3to4(byte[] threeBytes) { return encode3to4(threeBytes, 3); } // end encodeToBytes
/** * Suspends encoding of the stream. May be helpful if you need to embed * a piece of base640-encoded data in a stream. * * @since 1.5.1 */ public void suspendEncoding() throws java.io.IOException { flushBase64(); this.suspendEncoding = true; } // end suspendEncoding
/** * Serializes an object and returns the Base64-encoded version of that * serialized object. If the object cannot be serialized or there is another * error, the method will return <tt>null</tt>. The object is not * GZip-compressed before being encoded. * * @param serializableObject * The object to encode * @return The Base64-encoded object * @since 1.4 */ public static String encodeObject(java.io.Serializable serializableObject) { return encodeObject(serializableObject, NO_OPTIONS); } // end encodeObject
/** * Decodes the first four bytes of array <var>fourBytes</var> and returns * an array up to three bytes long with the decoded values. * * @param fourBytes * the array with Base64 content * @return array with decoded values * @since 1.3 */ private static byte[] decode4to3(byte[] fourBytes) { byte[] outBuff1 = new byte[3]; int count = decode4to3(fourBytes, 0, outBuff1, 0); byte[] outBuff2 = new byte[count]; for (int i = 0; i < count; i++) outBuff2[i] = outBuff1[i]; return outBuff2; }
/** * Get the syntax type of this DataThing. The type string is based around * application of the collection type constructors to a base MIME type. For * example, t(s('text/plain')) is a tree of sets of TEXT/PLAIN items. The * MIME type may be a comma separated list of types. Possible type * constructors are t(..) for trees, s(..) for sets, l(..) for lists and * p(..) for partial orders. * <p> * I would imagine that we'll mostly be dealing with types of 'text/plain', * lists of same and maybe the occasional 'image/png' or similar, but I * think this has enough flexibility to cover most things. * <p> * The type string "null" represents and empty DataThing and is the default * value returned if the collection is empty. */ public String getSyntacticType() { return getSyntacticTypeForObject(theDataObject); }
/** * For arrays of byte arrays store each byte array in a List */ public static DataThing bake(byte[][] theByteArrayArray) { return new DataThing(convertObject(theByteArrayArray)); /** * List theList = new ArrayList(); for (int i = 0; i < * theByteArrayArray.length; i++) { theList.add(theByteArrayArray[i]); } * return new DataThing(theList); */ }
DataThing makeSingle() { return new DataThing("1"); }
/** * Returns a particularly dumb implementation of a unique identifier */ public synchronized String getID(LSIDProvider.NamespaceEnumeration namespace) { return "urn:lsid:net.sf.taverna:" + namespace.toString() + ":" + (count++); } }
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source * The data to convert * @param off * Offset in array where conversion should begin * @param len * Length of data to convert * @since 1.4 */ public static String encodeBytes(byte[] source, int off, int len) { return encodeBytes(source, off, len, NO_OPTIONS); } // end encodeBytes
/** * Encodes up to the first three bytes of array <var>threeBytes</var> and * returns a four-byte array in Base64 notation. The actual number of * significant bytes in your array is given by <var>numSigBytes</var>. The * array <var>threeBytes</var> needs only be as big as <var>numSigBytes</var>. * * @param threeBytes * the array to convert * @param numSigBytes * the number of significant bytes in your array * @return four byte array in Base64 notation. * @since 1.3 */ private static byte[] encode3to4(byte[] threeBytes, int numSigBytes) { byte[] dest = new byte[4]; encode3to4(threeBytes, 0, numSigBytes, dest, 0); return dest; }
/** * Easy for String objects, everything already recognizes them so no custom * code required. */ public static DataThing bake(String theString) { return new DataThing(convertObject(theString)); }