Function to serialize the given list of Vector clocks into a string. If
something goes wrong, it returns an empty string.

@param vectorClocks The Vector clock list to serialize
@return The string (JSON) version of the specified Vector clock
350081
public static String getSerializedVectorClocks(List<VectorClock> vectorClocks) {
        List<VectorClockWrapper> vectorClockWrappers = new ArrayList<VectorClockWrapper>();
        for(VectorClock vc: vectorClocks) {
            vectorClockWrappers.add(new VectorClockWrapper(vc));
        }
        String serializedVC = "";
        try {
            serializedVC = mapper.writeValueAsString(vectorClockWrappers);
        } catch(Exception e) {
            e.printStackTrace();
        }
        return serializedVC;
    }
857142
public void setTimexFreq(String v) {
    if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexFreq == null)
      jcasType.jcas.throwFeatMissing("timexFreq", "de.unihd.dbs.uima.types.heideltime.Timex3");
    jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexFreq, v);}
828440
public ObjectArrayList times(int times) {
	ObjectArrayList newList = new ObjectArrayList(times*size);
	for (int i=times; --i >= 0; ) {
		newList.addAllOfFromTo(this,0,size()-1);
	}
	return newList;
}
19947
public String getTimexFreq() {
    if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexFreq == null)
      jcasType.jcas.throwFeatMissing("timexFreq", "de.unihd.dbs.uima.types.heideltime.Timex3");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexFreq);}
492990
String getSyncTimes() {
    StringBuilder buf = new StringBuilder();
    for (JournalAndStream jas : journals) {
      if (jas.isActive()) {
        buf.append(jas.getCurrentStream().getTotalSyncTime());
        buf.append(" ");
      }
    }
    return buf.toString();
  }
807722
private Deferred<ChannelBuffer> serialize() throws Exception {
    final long start = System.currentTimeMillis();
    // buffers and an array list to stored the deferreds
    final ChannelBuffer response = ChannelBuffers.dynamicBuffer();
    final OutputStream output_stream = new ChannelBufferOutputStream(response);

    final JsonGenerator json = JSON.getFactory().createGenerator(output_stream);
    json.writeStartObject();
    json.writeFieldName("outputs");
    json.writeStartArray();

    // We want the serializer to execute serially so we need to create a callback
    // chain so that when one DPsResolver is finished, it triggers the next to
    // start serializing.
    final Deferred<Object> cb_chain = new Deferred<Object>();

    // default to the expressions if there, or fall back to the metrics
    final List<Output> outputs;
    if (query.getOutputs() == null || query.getOutputs().isEmpty()) {
      if (query.getExpressions() != null && !query.getExpressions().isEmpty()) {
        outputs = new ArrayList<Output>(query.getExpressions().size());
        for (final Expression exp : query.getExpressions()) {
          outputs.add(Output.Builder().setId(exp.getId()).build());
        }
      } else if (query.getMetrics() != null && !query.getMetrics().isEmpty()) {
        outputs = new ArrayList<Output>(query.getMetrics().size());
        for (final Metric metric : query.getMetrics()) {
          outputs.add(Output.Builder().setId(metric.getId()).build());
        }
      } else {
        throw new IllegalArgumentException(
            "How did we get here?? No metrics or expressions??");
      }
    } else {
      outputs = query.getOutputs();
    }

    for (final Output output : outputs) {
      if (expressions != null) {
        final ExpressionIterator it = expressions.get(output.getId());
        if (it != null) {
          cb_chain.addCallback(new SerializeExpressionIterator(tsdb, json, 
              output, it, ts_query));
          continue;
        }
      }

      if (query.getMetrics() != null && !query.getMetrics().isEmpty()) {
        final TSSubQuery sub = sub_queries.get(output.getId());
        if (sub != null) {
          final TimeSyncedIterator it = new TimeSyncedIterator(output.getId(), 
              sub.getFilterTagKs(), sub_query_results.get(output.getId()));
          cb_chain.addCallback(new SerializeSubIterator(tsdb, json, output, it));
          continue;
        }
      } else {
        LOG.warn("Couldn't find a variable matching: " + output.getId() + 
            " in query " + query);
      }
    }
  
    /** Final callback to close out the JSON array and return our results */
    class FinalCB implements Callback<ChannelBuffer, Object> {
      public ChannelBuffer call(final Object obj)
          throws Exception {
        json.writeEndArray();
        
//        ts_query.getQueryStats().setTimeSerialization(
//            DateTime.currentTimeMillis() - start);
        ts_query.getQueryStats().markSerializationSuccessful();

        // dump overall stats as an extra object in the array
//        if (true) {
//          final QueryStats stats = ts_query.getQueryStats();
//          json.writeFieldName("statsSummary");
//          json.writeStartObject();
//          //json.writeStringField("hostname", TSDB.getHostname());
//          //json.writeNumberField("runningQueries", stats.getNumRunningQueries());
//          json.writeNumberField("datapoints", stats.getAggregatedSize());
//          json.writeNumberField("rawDatapoints", stats.getSize());
//          //json.writeNumberField("rowsFetched", stats.getRowsFetched());
//          json.writeNumberField("aggregationTime", stats.getTimeAggregation());
//          json.writeNumberField("serializationTime", stats.getTimeSerialization());
//          json.writeNumberField("storageTime", stats.getTimeStorage());
//          json.writeNumberField("timeTotal", 
//              ((double)stats.getTimeTotal() / (double)1000000));
//          json.writeEndObject();
//        }
        
        // dump the original query
        if (true) {
          json.writeFieldName("query");
          json.writeObject(QueryExecutor.this.query);
        }
        // IMPORTANT Make sure the close the JSON array and the generator
        json.writeEndObject();
        json.close();
        return response;
      }
    }

    // trigger the callback chain here
    cb_chain.callback(null);
    return cb_chain.addCallback(new FinalCB());
  }
778835
public JSONArray jsonifyValues() {
        JSONArray jValues = new JSONArray();
        for (ValueEntry vEntry : values) {
            JSONObject o = new JSONObject();
            o.put("value",vEntry.getValue());
            o.put("timestamp",vEntry.getTimestamp());
            jValues.add(o);
        }
        return jValues;
    }
1307409
public static VectorClock makeClock(Set<Integer> serverIds, long clockValue, long timestamp) {
        List<ClockEntry> clockEntries = new ArrayList<ClockEntry>(serverIds.size());
        for(Integer serverId: serverIds) {
            clockEntries.add(new ClockEntry(serverId.shortValue(), clockValue));
        }
        return new VectorClock(clockEntries, timestamp);
    }
961303
public void writeObject(Object object)
        throws IOException
    {
        if (object == null)
            writeNull();
        else if (object instanceof String)
            writeString((String) object);
        else if (object instanceof Boolean)
            writeBoolean(((Boolean) object).booleanValue());
        else if (object instanceof Integer)
            writeInt(((Integer) object).intValue());
        else if (object instanceof Long)
            writeLong(((Long) object).longValue());
        else if (object instanceof Date)
            writeUTCDate(((Date) object).getTime());
        else if (object instanceof byte[]) {
            byte[] data = (byte[]) object;
            writeBytes(data, 0, data.length);
        }
        else if (object instanceof Vector) {
            Vector vector = (Vector) object;

            int size = vector.size();
            writeListBegin(size, null);
            for (int i = 0; i < size; i++)
                writeObject(vector.elementAt(i));

            writeListEnd();
        }
        else if (object instanceof Hashtable) {
            Hashtable hashtable = (Hashtable) object;

            writeMapBegin(null);
            Enumeration e = hashtable.keys();
            while (e.hasMoreElements()) {
                Object key = e.nextElement();
                Object value = hashtable.get(key);

                writeObject(key);
                writeObject(value);
            }
            writeMapEnd();
        }
        else
            writeCustomObject(object);
    }

    /**
     * Applications which override this can do custom serialization.
     *
     * @param object the object to write.
     */
    public void writeCustomObject(Object object)
        throws IOException
    {
        throw new IOException("unexpected object: " + object);
    }

    /**
     * Writes the list header to the stream.  List writers will call
     * <code>writeListBegin</code> followed by the list contents and then
     * call <code>writeListEnd</code>.
     *
     * <code><pre>
     * &lt;list>
     *   &lt;type>java.util.ArrayList&lt;/type>
     *   &lt;length>3&lt;/length>
     *   &lt;int>1&lt;/int>
     *   &lt;int>2&lt;/int>
     *   &lt;int>3&lt;/int>
     * &lt;/list>
     * </pre></code>
     */
    public void writeListBegin(int length, String type)
        throws IOException
    {
        os.write('V');
        os.write('t');
        printLenString(type);

        os.write('l');
        os.write(length >> 24);
        os.write(length >> 16);
        os.write(length >> 8);
        os.write(length);
    }

    /**
     * Writes the tail of the list to the stream.
     */
    public void writeListEnd()
        throws IOException
    {
        os.write('z');
    }

    /**
     * Writes the map header to the stream.  Map writers will call
     * <code>writeMapBegin</code> followed by the map contents and then
     * call <code>writeMapEnd</code>.
     *
     * <code><pre>
     * Mt b16 b8 type (<key> <value>)z
     * </pre></code>
     */
    public void writeMapBegin(String type)
        throws IOException
    {
        os.write('M');
        os.write('t');
        printLenString(type);
    }

    /**
     * Writes the tail of the map to the stream.
     */
    public void writeMapEnd()
        throws IOException
    {
        os.write('z');
    }

    /**
     * Writes a remote object reference to the stream.  The type is the
     * type of the remote interface.
     *
     * <code><pre>
     * 'r' 't' b16 b8 type url
     * </pre></code>
     */
    public void writeRemote(String type, String url)
        throws IOException
    {
        os.write('r');
        os.write('t');
        printLenString(type);
        os.write('S');
        printLenString(url);
    }

    /**
     * Prints a string to the stream, encoded as UTF-8 with preceeding length
     *
     * @param v the string to print.
     */
    public void printLenString(String v)
        throws IOException
    {
        if (v == null) {
            os.write(0);
            os.write(0);
        }
        else {
            int len = v.length();
            os.write(len >> 8);
            os.write(len);

            printString(v, 0, len);
        }
    }

    /**
     * Prints a string to the stream, encoded as UTF-8
     *
     * @param v the string to print.
     */
    public void printString(String v)
        throws IOException
    {
        printString(v, 0, v.length());
    }

    /**
     * Prints a string to the stream, encoded as UTF-8
     *
     * @param v the string to print.
     */
    public void printString(String v, int offset, int length)
        throws IOException
    {
        for (int i = 0; i < length; i++) {
            char ch = v.charAt(i + offset);

            if (ch < 0x80)
                os.write(ch);
            else if (ch < 0x800) {
                os.write(0xc0 + ((ch >> 6) & 0x1f));
                os.write(0x80 + (ch & 0x3f));
            }
            else {
                os.write(0xe0 + ((ch >> 12) & 0xf));
                os.write(0x80 + ((ch >> 6) & 0x3f));
                os.write(0x80 + (ch & 0x3f));
            }
        }
    }
}
942174
public VectorClock incremented(int nodeId, long time) {
        VectorClock copyClock = this.clone();
        copyClock.incrementVersion(nodeId, time);
        return copyClock;
    }
610389
public static String serialize(Object[] objs)
    {
        StringBuffer buff = new StringBuffer();
        for(int i = 0; i < objs.length; i++)
        {
            if(objs[i] != null)
            {
                buff.append(objs[i].toString());
                if(i != objs.length-1)
                    buff.append(",");
            }
        }
        return buff.toString();
    }
804049
def json_serial(obj):
    """"""
    if isinstance(obj, datetime):
        serial = obj.isoformat()
        return serial
    raise TypeError("Type not serializable")
1114749
protected String serializeFromMap(@Nullable String user, long start, long duration, @Nullable List<String> roles, Map<String, Object> nameAndValMap) {
		return serializeFromMap(user, start, duration, toArr(roles), nameAndValMap);
	}
13930
private String[] stringVect2StringArray(final Vector v) {
        final String[] array = new String[v.size()];
        for (int i = 0; i < v.size(); i++) {
            array[i] = (String) v.elementAt(i);
        }
        return array;
    }
976001
private String getCDCQueryJson(CDCQuery cdcQuery) throws SerializationException {
		ObjectMapper mapper = getObjectMapper();
		String json = null;
		try {
			json = mapper.writeValueAsString(cdcQuery);
		} catch (Exception e) {
			throw new SerializationException(e);
		}

		return json;
	}
96451
Stream<String> writeTimeGauge(TimeGauge timeGauge) {
        Double value = timeGauge.value(getBaseTimeUnit());
        if (Double.isFinite(value)) {
            return Stream.of(writeMetric(timeGauge.getId(), config().clock().wallTime(), value));
        }
        return Stream.empty();
    }
803769
public String toJSON(List<JTSFeature> list) {
		Object fcJSON = this.startFeatureCollection();
		for (JTSFeature feature : list) {
			Object f = this.startFeature();
			Object p = this.startPoint();
			try {
				this.addXToPoint(feature.getGeometry().getGeometry()
						.getCentroid().getX(), p);
				this.addYToPoint(feature.getGeometry().getGeometry()
						.getCentroid().getY(), p);
			} catch (BaseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			Iterator it = feature.getAttributes().keySet().iterator();
			while (it.hasNext()) {
				String key = it.next().toString();
				this.addElementToFeature(feature.getAttribute(key).value, key,
						f);
			}

			p = this.endPoint(p, null, null);
			this.addPointToFeature(f, p);
			this.endFeature(f);
			this.addFeatureToCollection(fcJSON, f);
		}

		fcJSON = this.endFeatureCollection(fcJSON);

		return this.featureCollectionAsJSON((org.json.JSONObject) fcJSON);
	}