repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
dkpro/dkpro-argumentation
dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java
ArgumentUnitUtils.setProperty
public static String setProperty(ArgumentUnit argumentUnit, String propertyName, String propertyValue) { Properties properties = ArgumentUnitUtils.getProperties(argumentUnit); String result = (String) properties.setProperty(propertyName, propertyValue); ArgumentUnitUtils.setProperties(argumentUnit, properties); return result; }
java
public static String setProperty(ArgumentUnit argumentUnit, String propertyName, String propertyValue) { Properties properties = ArgumentUnitUtils.getProperties(argumentUnit); String result = (String) properties.setProperty(propertyName, propertyValue); ArgumentUnitUtils.setProperties(argumentUnit, properties); return result; }
[ "public", "static", "String", "setProperty", "(", "ArgumentUnit", "argumentUnit", ",", "String", "propertyName", ",", "String", "propertyValue", ")", "{", "Properties", "properties", "=", "ArgumentUnitUtils", ".", "getProperties", "(", "argumentUnit", ")", ";", "Str...
Sets the property @param argumentUnit argument component @param propertyName property name @param propertyValue property value @return the previous value of the specified key in this property list, or {@code null} if it did not have one.
[ "Sets", "the", "property" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java#L152-L160
train
dkpro/dkpro-argumentation
dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java
ArgumentUnitUtils.getProperty
public static String getProperty(ArgumentUnit argumentUnit, String propertyName) { Properties properties = ArgumentUnitUtils.getProperties(argumentUnit); return (String) properties.get(propertyName); }
java
public static String getProperty(ArgumentUnit argumentUnit, String propertyName) { Properties properties = ArgumentUnitUtils.getProperties(argumentUnit); return (String) properties.get(propertyName); }
[ "public", "static", "String", "getProperty", "(", "ArgumentUnit", "argumentUnit", ",", "String", "propertyName", ")", "{", "Properties", "properties", "=", "ArgumentUnitUtils", ".", "getProperties", "(", "argumentUnit", ")", ";", "return", "(", "String", ")", "pro...
Returns the property value @param argumentUnit argument component @param propertyName property name @return the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key
[ "Returns", "the", "property", "value" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java#L170-L174
train
dkpro/dkpro-argumentation
dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java
ArgumentUnitUtils.isImplicit
public static boolean isImplicit(ArgumentUnit argumentUnit) throws IllegalStateException { // is the implicit flag set? String implicitProperty = ArgumentUnitUtils.getProperty(argumentUnit, ArgumentUnitUtils.PROP_KEY_IS_IMPLICIT); // is the length really zero? int length = argumentUnit.getEnd() - argumentUnit.getBegin(); boolean zeroSize = length == 0; if (implicitProperty != null && Boolean.valueOf(implicitProperty) && zeroSize) { return true; } if (implicitProperty == null && !zeroSize) { return false; } throw new IllegalStateException( "argumentUnit is inconsistent. 'implicit' flag: " + implicitProperty + ", but length: " + length); }
java
public static boolean isImplicit(ArgumentUnit argumentUnit) throws IllegalStateException { // is the implicit flag set? String implicitProperty = ArgumentUnitUtils.getProperty(argumentUnit, ArgumentUnitUtils.PROP_KEY_IS_IMPLICIT); // is the length really zero? int length = argumentUnit.getEnd() - argumentUnit.getBegin(); boolean zeroSize = length == 0; if (implicitProperty != null && Boolean.valueOf(implicitProperty) && zeroSize) { return true; } if (implicitProperty == null && !zeroSize) { return false; } throw new IllegalStateException( "argumentUnit is inconsistent. 'implicit' flag: " + implicitProperty + ", but length: " + length); }
[ "public", "static", "boolean", "isImplicit", "(", "ArgumentUnit", "argumentUnit", ")", "throws", "IllegalStateException", "{", "// is the implicit flag set?", "String", "implicitProperty", "=", "ArgumentUnitUtils", ".", "getProperty", "(", "argumentUnit", ",", "ArgumentUnit...
Returns true is the argumentUnit length is 0 and flag is set to implicit. If length is greater than zero and flag is not set to implicit, returns false. In any other case, throws an exception @param argumentUnit argument unit @return boolean @throws java.lang.IllegalStateException if the implicit flag and length are inconsistent
[ "Returns", "true", "is", "the", "argumentUnit", "length", "is", "0", "and", "flag", "is", "set", "to", "implicit", ".", "If", "length", "is", "greater", "than", "zero", "and", "flag", "is", "not", "set", "to", "implicit", "returns", "false", ".", "In", ...
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java#L185-L207
train
dkpro/dkpro-argumentation
dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java
ArgumentUnitUtils.setIsImplicit
public static void setIsImplicit(ArgumentUnit argumentUnit, boolean implicit) throws IllegalArgumentException { int length = argumentUnit.getEnd() - argumentUnit.getBegin(); if (length > 0) { throw new IllegalArgumentException("Cannot set 'implicit' property to component " + "with non-zero length (" + length + ")"); } ArgumentUnitUtils.setProperty(argumentUnit, ArgumentUnitUtils.PROP_KEY_IS_IMPLICIT, Boolean.valueOf(implicit).toString()); }
java
public static void setIsImplicit(ArgumentUnit argumentUnit, boolean implicit) throws IllegalArgumentException { int length = argumentUnit.getEnd() - argumentUnit.getBegin(); if (length > 0) { throw new IllegalArgumentException("Cannot set 'implicit' property to component " + "with non-zero length (" + length + ")"); } ArgumentUnitUtils.setProperty(argumentUnit, ArgumentUnitUtils.PROP_KEY_IS_IMPLICIT, Boolean.valueOf(implicit).toString()); }
[ "public", "static", "void", "setIsImplicit", "(", "ArgumentUnit", "argumentUnit", ",", "boolean", "implicit", ")", "throws", "IllegalArgumentException", "{", "int", "length", "=", "argumentUnit", ".", "getEnd", "(", ")", "-", "argumentUnit", ".", "getBegin", "(", ...
Sets the implicit value to the argument @param argumentUnit argument unit @param implicit boolean value @throws java.lang.IllegalArgumentException if the length of argument is non-zero
[ "Sets", "the", "implicit", "value", "to", "the", "argument" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java#L216-L228
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DSet.java
DSet.newDSet
public static <E extends DSet.Entry> DSet<E> newDSet (Iterable<? extends E> source) { return new DSet<E>(source); }
java
public static <E extends DSet.Entry> DSet<E> newDSet (Iterable<? extends E> source) { return new DSet<E>(source); }
[ "public", "static", "<", "E", "extends", "DSet", ".", "Entry", ">", "DSet", "<", "E", ">", "newDSet", "(", "Iterable", "<", "?", "extends", "E", ">", "source", ")", "{", "return", "new", "DSet", "<", "E", ">", "(", "source", ")", ";", "}" ]
Creates a new DSet of the appropriate generic type.
[ "Creates", "a", "new", "DSet", "of", "the", "appropriate", "generic", "type", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DSet.java#L83-L86
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DSet.java
DSet.writeObject
public void writeObject (ObjectOutputStream out) throws IOException { out.writeInt(_size); for (int ii = 0; ii < _size; ii++) { out.writeObject(_entries[ii]); } }
java
public void writeObject (ObjectOutputStream out) throws IOException { out.writeInt(_size); for (int ii = 0; ii < _size; ii++) { out.writeObject(_entries[ii]); } }
[ "public", "void", "writeObject", "(", "ObjectOutputStream", "out", ")", "throws", "IOException", "{", "out", ".", "writeInt", "(", "_size", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "_size", ";", "ii", "++", ")", "{", "out", ".", ...
Custom writer method. @see Streamable.
[ "Custom", "writer", "method", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DSet.java#L497-L504
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DSet.java
DSet.readObject
public void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { _size = in.readInt(); // ensure our capacity is a power of 2 (for consistency) int capacity = INITIAL_CAPACITY; while (capacity < _size) { capacity <<= 1; } @SuppressWarnings("unchecked") E[] entries = (E[])new Entry[capacity]; _entries = entries; for (int ii = 0; ii < _size; ii++) { @SuppressWarnings("unchecked") E entry = (E)in.readObject(); _entries[ii] = entry; } }
java
public void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { _size = in.readInt(); // ensure our capacity is a power of 2 (for consistency) int capacity = INITIAL_CAPACITY; while (capacity < _size) { capacity <<= 1; } @SuppressWarnings("unchecked") E[] entries = (E[])new Entry[capacity]; _entries = entries; for (int ii = 0; ii < _size; ii++) { @SuppressWarnings("unchecked") E entry = (E)in.readObject(); _entries[ii] = entry; } }
[ "public", "void", "readObject", "(", "ObjectInputStream", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "_size", "=", "in", ".", "readInt", "(", ")", ";", "// ensure our capacity is a power of 2 (for consistency)", "int", "capacity", "=", "IN...
Custom reader method. @see Streamable.
[ "Custom", "reader", "method", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DSet.java#L507-L522
train
threerings/narya
core/src/main/java/com/threerings/io/ObjectInputStream.java
ObjectInputStream.addTranslation
public void addTranslation (String oldname, String newname) { if (_translations == null) { _translations = Maps.newHashMap(); } _translations.put(oldname, newname); }
java
public void addTranslation (String oldname, String newname) { if (_translations == null) { _translations = Maps.newHashMap(); } _translations.put(oldname, newname); }
[ "public", "void", "addTranslation", "(", "String", "oldname", ",", "String", "newname", ")", "{", "if", "(", "_translations", "==", "null", ")", "{", "_translations", "=", "Maps", ".", "newHashMap", "(", ")", ";", "}", "_translations", ".", "put", "(", "...
Configures this object input stream with a mapping from an old class name to a new one. Serialized instances of the old class name will use the new class name when unserializing.
[ "Configures", "this", "object", "input", "stream", "with", "a", "mapping", "from", "an", "old", "class", "name", "to", "a", "new", "one", ".", "Serialized", "instances", "of", "the", "old", "class", "name", "will", "use", "the", "new", "class", "name", "...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ObjectInputStream.java#L67-L73
train
threerings/narya
core/src/main/java/com/threerings/io/ObjectInputStream.java
ObjectInputStream.readIntern
public String readIntern () throws IOException { // create our intern map if necessary if (_internmap == null) { _internmap = Lists.newArrayList(); // insert a zeroth element _internmap.add(null); } // read in the intern code for this instance short code = readShort(); // a zero code indicates a null value if (code == 0) { return null; // if the code is negative, that means that we've never seen if before and value follows } else if (code < 0) { // first swap the code into positive-land code *= -1; // read in the value String value = readUTF().intern(); // create the mapping and return the value mapIntern(code, value); return value; } else { String value = (code < _internmap.size()) ? _internmap.get(code) : null; // sanity check if (value == null) { // this will help with debugging log.warning("Internal stream error, no intern value", "code", code, "ois", this, new Exception()); log.warning("ObjectInputStream mappings", "map", _internmap); String errmsg = "Read intern code for which we have no registered value " + "metadata [code=" + code + "]"; throw new RuntimeException(errmsg); } return value; } }
java
public String readIntern () throws IOException { // create our intern map if necessary if (_internmap == null) { _internmap = Lists.newArrayList(); // insert a zeroth element _internmap.add(null); } // read in the intern code for this instance short code = readShort(); // a zero code indicates a null value if (code == 0) { return null; // if the code is negative, that means that we've never seen if before and value follows } else if (code < 0) { // first swap the code into positive-land code *= -1; // read in the value String value = readUTF().intern(); // create the mapping and return the value mapIntern(code, value); return value; } else { String value = (code < _internmap.size()) ? _internmap.get(code) : null; // sanity check if (value == null) { // this will help with debugging log.warning("Internal stream error, no intern value", "code", code, "ois", this, new Exception()); log.warning("ObjectInputStream mappings", "map", _internmap); String errmsg = "Read intern code for which we have no registered value " + "metadata [code=" + code + "]"; throw new RuntimeException(errmsg); } return value; } }
[ "public", "String", "readIntern", "(", ")", "throws", "IOException", "{", "// create our intern map if necessary", "if", "(", "_internmap", "==", "null", ")", "{", "_internmap", "=", "Lists", ".", "newArrayList", "(", ")", ";", "// insert a zeroth element", "_intern...
Reads a pooled string value from the input stream.
[ "Reads", "a", "pooled", "string", "value", "from", "the", "input", "stream", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ObjectInputStream.java#L109-L153
train
threerings/narya
core/src/main/java/com/threerings/io/ObjectInputStream.java
ObjectInputStream.readClassMapping
protected ClassMapping readClassMapping () throws IOException, ClassNotFoundException { // create our classmap if necessary if (_classmap == null) { _classmap = Lists.newArrayList(); // insert a zeroth element _classmap.add(null); } // read in the class code for this instance short code = readShort(); // a zero code indicates a null value if (code == 0) { return null; // if the code is negative, that means that we've never seen it before and class // metadata follows } else if (code < 0) { // first swap the code into positive-land code *= -1; // read in the class metadata String cname = readUTF(); // if we have a translation (used to cope when serialized classes are renamed) use // it if (_translations != null) { String tname = _translations.get(cname); if (tname != null) { cname = tname; } } // create the class mapping return mapClass(code, cname); } else { ClassMapping cmap = (code < _classmap.size()) ? _classmap.get(code) : null; // sanity check if (cmap == null) { // this will help with debugging log.warning("Internal stream error, no class metadata", "code", code, "ois", this, new Exception()); log.warning("ObjectInputStream mappings", "map", _classmap); String errmsg = "Read object code for which we have no registered class " + "metadata [code=" + code + "]"; throw new RuntimeException(errmsg); } return cmap; } }
java
protected ClassMapping readClassMapping () throws IOException, ClassNotFoundException { // create our classmap if necessary if (_classmap == null) { _classmap = Lists.newArrayList(); // insert a zeroth element _classmap.add(null); } // read in the class code for this instance short code = readShort(); // a zero code indicates a null value if (code == 0) { return null; // if the code is negative, that means that we've never seen it before and class // metadata follows } else if (code < 0) { // first swap the code into positive-land code *= -1; // read in the class metadata String cname = readUTF(); // if we have a translation (used to cope when serialized classes are renamed) use // it if (_translations != null) { String tname = _translations.get(cname); if (tname != null) { cname = tname; } } // create the class mapping return mapClass(code, cname); } else { ClassMapping cmap = (code < _classmap.size()) ? _classmap.get(code) : null; // sanity check if (cmap == null) { // this will help with debugging log.warning("Internal stream error, no class metadata", "code", code, "ois", this, new Exception()); log.warning("ObjectInputStream mappings", "map", _classmap); String errmsg = "Read object code for which we have no registered class " + "metadata [code=" + code + "]"; throw new RuntimeException(errmsg); } return cmap; } }
[ "protected", "ClassMapping", "readClassMapping", "(", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "// create our classmap if necessary", "if", "(", "_classmap", "==", "null", ")", "{", "_classmap", "=", "Lists", ".", "newArrayList", "(", ")", "...
Reads a class mapping from the stream. @return the class mapping, or <code>null</code> to represent a null value.
[ "Reads", "a", "class", "mapping", "from", "the", "stream", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ObjectInputStream.java#L169-L221
train
threerings/narya
core/src/main/java/com/threerings/io/ObjectInputStream.java
ObjectInputStream.mapClass
protected ClassMapping mapClass (short code, String cname) throws IOException, ClassNotFoundException { // create a class mapping record, and cache it ClassMapping cmap = createClassMapping(code, cname); _classmap.add(code, cmap); return cmap; }
java
protected ClassMapping mapClass (short code, String cname) throws IOException, ClassNotFoundException { // create a class mapping record, and cache it ClassMapping cmap = createClassMapping(code, cname); _classmap.add(code, cmap); return cmap; }
[ "protected", "ClassMapping", "mapClass", "(", "short", "code", ",", "String", "cname", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "// create a class mapping record, and cache it", "ClassMapping", "cmap", "=", "createClassMapping", "(", "code", ",", ...
Creates, adds, and returns the class mapping for the specified code and class name.
[ "Creates", "adds", "and", "returns", "the", "class", "mapping", "for", "the", "specified", "code", "and", "class", "name", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ObjectInputStream.java#L226-L233
train
threerings/narya
core/src/main/java/com/threerings/io/ObjectInputStream.java
ObjectInputStream.createClassMapping
protected ClassMapping createClassMapping (short code, String cname) throws IOException, ClassNotFoundException { // resolve the class and streamer ClassLoader loader = (_loader != null) ? _loader : Thread.currentThread().getContextClassLoader(); Class<?> sclass = Class.forName(cname, true, loader); Streamer streamer = Streamer.getStreamer(sclass); if (STREAM_DEBUG) { log.info(hashCode() + ": New class '" + cname + "'", "code", code); } // sanity check if (streamer == null) { String errmsg = "Aiya! Unable to create streamer for newly seen class " + "[code=" + code + ", class=" + cname + "]"; throw new RuntimeException(errmsg); } return new ClassMapping(code, sclass, streamer); }
java
protected ClassMapping createClassMapping (short code, String cname) throws IOException, ClassNotFoundException { // resolve the class and streamer ClassLoader loader = (_loader != null) ? _loader : Thread.currentThread().getContextClassLoader(); Class<?> sclass = Class.forName(cname, true, loader); Streamer streamer = Streamer.getStreamer(sclass); if (STREAM_DEBUG) { log.info(hashCode() + ": New class '" + cname + "'", "code", code); } // sanity check if (streamer == null) { String errmsg = "Aiya! Unable to create streamer for newly seen class " + "[code=" + code + ", class=" + cname + "]"; throw new RuntimeException(errmsg); } return new ClassMapping(code, sclass, streamer); }
[ "protected", "ClassMapping", "createClassMapping", "(", "short", "code", ",", "String", "cname", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "// resolve the class and streamer", "ClassLoader", "loader", "=", "(", "_loader", "!=", "null", ")", "?"...
Creates and returns a class mapping for the specified code and class name.
[ "Creates", "and", "returns", "a", "class", "mapping", "for", "the", "specified", "code", "and", "class", "name", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ObjectInputStream.java#L238-L258
train
threerings/narya
core/src/main/java/com/threerings/presents/client/DeltaCalculator.java
DeltaCalculator.gotPong
public boolean gotPong (PongResponse pong) { if (_ping == null) { // an errant pong that is likely being processed late after // a new connection was opened. return false; } // don't freak out if they keep calling gotPong() after we're done if (_iter >= _deltas.length) { return true; } // make a note of when the ping message was sent and when the pong // response was received (both in client time) long send = _ping.getPackStamp(), recv = pong.getUnpackStamp(); _ping = null; // clear out the saved sent ping // make a note of when the pong response was sent (in server time) // and the processing delay incurred on the server long server = pong.getPackStamp(), delay = pong.getProcessDelay(); // compute the network delay (round-trip time divided by two) long nettime = (recv - send - delay)/2; // the time delta is the client time when the pong was received // minus the server's send time (plus network delay): dT = C - S _deltas[_iter] = recv - (server + nettime); log.debug("Calculated delta", "delay", delay, "nettime", nettime, "delta", _deltas[_iter], "rtt", (recv-send)); return (++_iter >= CLOCK_SYNC_PING_COUNT); }
java
public boolean gotPong (PongResponse pong) { if (_ping == null) { // an errant pong that is likely being processed late after // a new connection was opened. return false; } // don't freak out if they keep calling gotPong() after we're done if (_iter >= _deltas.length) { return true; } // make a note of when the ping message was sent and when the pong // response was received (both in client time) long send = _ping.getPackStamp(), recv = pong.getUnpackStamp(); _ping = null; // clear out the saved sent ping // make a note of when the pong response was sent (in server time) // and the processing delay incurred on the server long server = pong.getPackStamp(), delay = pong.getProcessDelay(); // compute the network delay (round-trip time divided by two) long nettime = (recv - send - delay)/2; // the time delta is the client time when the pong was received // minus the server's send time (plus network delay): dT = C - S _deltas[_iter] = recv - (server + nettime); log.debug("Calculated delta", "delay", delay, "nettime", nettime, "delta", _deltas[_iter], "rtt", (recv-send)); return (++_iter >= CLOCK_SYNC_PING_COUNT); }
[ "public", "boolean", "gotPong", "(", "PongResponse", "pong", ")", "{", "if", "(", "_ping", "==", "null", ")", "{", "// an errant pong that is likely being processed late after", "// a new connection was opened.", "return", "false", ";", "}", "// don't freak out if they keep...
Must be called when the pong response arrives back from the server. @return true if we've iterated sufficiently many times to establish a stable time delta estimate.
[ "Must", "be", "called", "when", "the", "pong", "response", "arrives", "back", "from", "the", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/DeltaCalculator.java#L71-L103
train
threerings/narya
core/src/main/java/com/threerings/presents/util/SafeSubscriber.java
SafeSubscriber.subscribe
public void subscribe (DObjectManager omgr) { if (_active) { log.warning("Active safesub asked to resubscribe " + this + ".", new Exception()); return; } // note that we are now again in the "wishing to be subscribed" state _active = true; // make sure we dont have an object reference (which should be // logically impossible) if (_object != null) { log.warning("Incroyable! A safesub has an object and was " + "non-active!? " + this + ".", new Exception()); // make do in the face of insanity _subscriber.objectAvailable(_object); return; } if (_pending) { // we were previously asked to subscribe, then they asked to // unsubscribe and now they've asked to subscribe again, all // before the original subscription even completed; we need do // nothing here except as the original subscription request // will eventually come through and all will be well return; } // we're not pending and we just became active, that means we need // to request to subscribe to our object _pending = true; omgr.subscribeToObject(_oid, this); }
java
public void subscribe (DObjectManager omgr) { if (_active) { log.warning("Active safesub asked to resubscribe " + this + ".", new Exception()); return; } // note that we are now again in the "wishing to be subscribed" state _active = true; // make sure we dont have an object reference (which should be // logically impossible) if (_object != null) { log.warning("Incroyable! A safesub has an object and was " + "non-active!? " + this + ".", new Exception()); // make do in the face of insanity _subscriber.objectAvailable(_object); return; } if (_pending) { // we were previously asked to subscribe, then they asked to // unsubscribe and now they've asked to subscribe again, all // before the original subscription even completed; we need do // nothing here except as the original subscription request // will eventually come through and all will be well return; } // we're not pending and we just became active, that means we need // to request to subscribe to our object _pending = true; omgr.subscribeToObject(_oid, this); }
[ "public", "void", "subscribe", "(", "DObjectManager", "omgr", ")", "{", "if", "(", "_active", ")", "{", "log", ".", "warning", "(", "\"Active safesub asked to resubscribe \"", "+", "this", "+", "\".\"", ",", "new", "Exception", "(", ")", ")", ";", "return", ...
Initiates the subscription process.
[ "Initiates", "the", "subscription", "process", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/SafeSubscriber.java#L79-L112
train
threerings/narya
core/src/main/java/com/threerings/presents/util/SafeSubscriber.java
SafeSubscriber.unsubscribe
public void unsubscribe (DObjectManager omgr) { if (!_active) { // we may be non-active and have no object which could mean // that subscription failed; in which case we don't want to // complain about anything, just quietly ignore the // unsubscribe request if (_object == null && !_pending) { return; } log.warning("Inactive safesub asked to unsubscribe " + this + ".", new Exception()); } // note that we no longer desire to be subscribed _active = false; if (_pending) { // make sure we don't have an object reference if (_object != null) { log.warning("Incroyable! A safesub has an object and is " + "pending!? " + this + ".", new Exception()); } else { // nothing to do but wait for the subscription to complete // at which point we'll pitch the object post-haste return; } } // make sure we have our object if (_object == null) { log.warning("Zut alors! A safesub _was_ active and not " + "pending yet has no object!? " + this + ".", new Exception()); // nothing to do since we're apparently already unsubscribed return; } // clear out any listeners we added for (ChangeListener listener : _listeners) { _object.removeListener(listener); } // finally effect our unsubscription _object = null; omgr.unsubscribeFromObject(_oid, this); }
java
public void unsubscribe (DObjectManager omgr) { if (!_active) { // we may be non-active and have no object which could mean // that subscription failed; in which case we don't want to // complain about anything, just quietly ignore the // unsubscribe request if (_object == null && !_pending) { return; } log.warning("Inactive safesub asked to unsubscribe " + this + ".", new Exception()); } // note that we no longer desire to be subscribed _active = false; if (_pending) { // make sure we don't have an object reference if (_object != null) { log.warning("Incroyable! A safesub has an object and is " + "pending!? " + this + ".", new Exception()); } else { // nothing to do but wait for the subscription to complete // at which point we'll pitch the object post-haste return; } } // make sure we have our object if (_object == null) { log.warning("Zut alors! A safesub _was_ active and not " + "pending yet has no object!? " + this + ".", new Exception()); // nothing to do since we're apparently already unsubscribed return; } // clear out any listeners we added for (ChangeListener listener : _listeners) { _object.removeListener(listener); } // finally effect our unsubscription _object = null; omgr.unsubscribeFromObject(_oid, this); }
[ "public", "void", "unsubscribe", "(", "DObjectManager", "omgr", ")", "{", "if", "(", "!", "_active", ")", "{", "// we may be non-active and have no object which could mean", "// that subscription failed; in which case we don't want to", "// complain about anything, just quietly ignor...
Terminates the object subscription. If the initial subscription has not yet completed, the desire to terminate will be noted and the subscription will be terminated as soon as it completes.
[ "Terminates", "the", "object", "subscription", ".", "If", "the", "initial", "subscription", "has", "not", "yet", "completed", "the", "desire", "to", "terminate", "will", "be", "noted", "and", "the", "subscription", "will", "be", "terminated", "as", "soon", "as...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/SafeSubscriber.java#L119-L163
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/server/ChatHistory.java
ChatHistory.clear
public void clear (final Name username) { // if we're holding this username for a session observer, postpone until after the current // dispatch finishes if (_holds.contains(username)) { _holds.remove(username); _omgr.postRunnable(new Runnable () { public void run () { clear(username); } }); return; } // Log.info("Clearing history for " + username + "."); _histories.remove(username); }
java
public void clear (final Name username) { // if we're holding this username for a session observer, postpone until after the current // dispatch finishes if (_holds.contains(username)) { _holds.remove(username); _omgr.postRunnable(new Runnable () { public void run () { clear(username); } }); return; } // Log.info("Clearing history for " + username + "."); _histories.remove(username); }
[ "public", "void", "clear", "(", "final", "Name", "username", ")", "{", "// if we're holding this username for a session observer, postpone until after the current", "// dispatch finishes", "if", "(", "_holds", ".", "contains", "(", "username", ")", ")", "{", "_holds", "."...
Clears the chat history for the specified user.
[ "Clears", "the", "chat", "history", "for", "the", "specified", "user", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatHistory.java#L121-L137
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/server/ChatHistory.java
ChatHistory.prune
protected void prune (long now, List<Entry> history) { int prunepos = 0; for (int ll = history.size(); prunepos < ll; prunepos++) { Entry entry = history.get(prunepos); if (now - entry.message.timestamp < HISTORY_EXPIRATION) { break; // stop when we get to the first valid message } } history.subList(0, prunepos).clear(); }
java
protected void prune (long now, List<Entry> history) { int prunepos = 0; for (int ll = history.size(); prunepos < ll; prunepos++) { Entry entry = history.get(prunepos); if (now - entry.message.timestamp < HISTORY_EXPIRATION) { break; // stop when we get to the first valid message } } history.subList(0, prunepos).clear(); }
[ "protected", "void", "prune", "(", "long", "now", ",", "List", "<", "Entry", ">", "history", ")", "{", "int", "prunepos", "=", "0", ";", "for", "(", "int", "ll", "=", "history", ".", "size", "(", ")", ";", "prunepos", "<", "ll", ";", "prunepos", ...
Prunes all messages from this history which are expired.
[ "Prunes", "all", "messages", "from", "this", "history", "which", "are", "expired", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatHistory.java#L196-L206
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientResolver.java
ClientResolver.reportSuccess
protected void reportSuccess () { for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) { ClientResolutionListener crl = _listeners.get(ii); try { // add a reference for each listener _clobj.reference(); crl.clientResolved(_username, _clobj); } catch (Exception e) { log.warning("Client resolution listener choked in clientResolved() " + crl, e); } } }
java
protected void reportSuccess () { for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) { ClientResolutionListener crl = _listeners.get(ii); try { // add a reference for each listener _clobj.reference(); crl.clientResolved(_username, _clobj); } catch (Exception e) { log.warning("Client resolution listener choked in clientResolved() " + crl, e); } } }
[ "protected", "void", "reportSuccess", "(", ")", "{", "for", "(", "int", "ii", "=", "0", ",", "ll", "=", "_listeners", ".", "size", "(", ")", ";", "ii", "<", "ll", ";", "ii", "++", ")", "{", "ClientResolutionListener", "crl", "=", "_listeners", ".", ...
Reports success to our resolution listeners.
[ "Reports", "success", "to", "our", "resolution", "listeners", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientResolver.java#L170-L182
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientResolver.java
ClientResolver.reportFailure
protected void reportFailure (Exception cause) { for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) { ClientResolutionListener crl = _listeners.get(ii); try { crl.resolutionFailed(_username, cause); } catch (Exception e) { log.warning("Client resolution listener choked in resolutionFailed()", "crl", crl, "username", _username, "cause", cause, e); } } }
java
protected void reportFailure (Exception cause) { for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) { ClientResolutionListener crl = _listeners.get(ii); try { crl.resolutionFailed(_username, cause); } catch (Exception e) { log.warning("Client resolution listener choked in resolutionFailed()", "crl", crl, "username", _username, "cause", cause, e); } } }
[ "protected", "void", "reportFailure", "(", "Exception", "cause", ")", "{", "for", "(", "int", "ii", "=", "0", ",", "ll", "=", "_listeners", ".", "size", "(", ")", ";", "ii", "<", "ll", ";", "ii", "++", ")", "{", "ClientResolutionListener", "crl", "="...
Reports failure to our resolution listeners.
[ "Reports", "failure", "to", "our", "resolution", "listeners", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientResolver.java#L187-L198
train
xbib/marc
src/main/java/org/xbib/marc/xml/MarcContentHandler.java
MarcContentHandler.setMarcListener
public MarcContentHandler setMarcListener(String type, MarcListener listener) { this.listeners.put(type, listener); return this; }
java
public MarcContentHandler setMarcListener(String type, MarcListener listener) { this.listeners.put(type, listener); return this; }
[ "public", "MarcContentHandler", "setMarcListener", "(", "String", "type", ",", "MarcListener", "listener", ")", "{", "this", ".", "listeners", ".", "put", "(", "type", ",", "listener", ")", ";", "return", "this", ";", "}" ]
Set MARC listener for a specific record type. @param type the record type @param listener the MARC listener @return this handler
[ "Set", "MARC", "listener", "for", "a", "specific", "record", "type", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/xml/MarcContentHandler.java#L101-L104
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.moveTo
public boolean moveTo (int placeId) { // make sure the placeId is valid if (placeId < 0) { log.warning("Refusing moveTo(): invalid placeId " + placeId + "."); return false; } // first check to see if our observers are happy with this move request if (!mayMoveTo(placeId, null)) { return false; } // we need to call this both to mark that we're issuing a move request and to check to see // if the last issued request should be considered stale boolean refuse = checkRepeatMove(); // complain if we're over-writing a pending request if (_pendingPlaceId != -1) { // if the pending request has been outstanding more than a minute, go ahead and let // this new one through in an attempt to recover from dropped moveTo requests if (refuse) { log.warning("Refusing moveTo; We have a request outstanding", "ppid", _pendingPlaceId, "npid", placeId); return false; } else { log.warning("Overriding stale moveTo request", "ppid", _pendingPlaceId, "npid", placeId); } } // make a note of our pending place id _pendingPlaceId = placeId; // issue a moveTo request log.info("Issuing moveTo(" + placeId + ")."); _lservice.moveTo(placeId, new LocationService.MoveListener() { public void moveSucceeded (PlaceConfig config) { // handle the successful move didMoveTo(_pendingPlaceId, config); // and clear out the tracked pending oid _pendingPlaceId = -1; handlePendingForcedMove(); } public void requestFailed (String reason) { // clear out our pending request oid int placeId = _pendingPlaceId; _pendingPlaceId = -1; log.info("moveTo failed", "pid", placeId, "reason", reason); // let our observers know that something has gone horribly awry handleFailure(placeId, reason); handlePendingForcedMove(); } }); return true; }
java
public boolean moveTo (int placeId) { // make sure the placeId is valid if (placeId < 0) { log.warning("Refusing moveTo(): invalid placeId " + placeId + "."); return false; } // first check to see if our observers are happy with this move request if (!mayMoveTo(placeId, null)) { return false; } // we need to call this both to mark that we're issuing a move request and to check to see // if the last issued request should be considered stale boolean refuse = checkRepeatMove(); // complain if we're over-writing a pending request if (_pendingPlaceId != -1) { // if the pending request has been outstanding more than a minute, go ahead and let // this new one through in an attempt to recover from dropped moveTo requests if (refuse) { log.warning("Refusing moveTo; We have a request outstanding", "ppid", _pendingPlaceId, "npid", placeId); return false; } else { log.warning("Overriding stale moveTo request", "ppid", _pendingPlaceId, "npid", placeId); } } // make a note of our pending place id _pendingPlaceId = placeId; // issue a moveTo request log.info("Issuing moveTo(" + placeId + ")."); _lservice.moveTo(placeId, new LocationService.MoveListener() { public void moveSucceeded (PlaceConfig config) { // handle the successful move didMoveTo(_pendingPlaceId, config); // and clear out the tracked pending oid _pendingPlaceId = -1; handlePendingForcedMove(); } public void requestFailed (String reason) { // clear out our pending request oid int placeId = _pendingPlaceId; _pendingPlaceId = -1; log.info("moveTo failed", "pid", placeId, "reason", reason); // let our observers know that something has gone horribly awry handleFailure(placeId, reason); handlePendingForcedMove(); } }); return true; }
[ "public", "boolean", "moveTo", "(", "int", "placeId", ")", "{", "// make sure the placeId is valid", "if", "(", "placeId", "<", "0", ")", "{", "log", ".", "warning", "(", "\"Refusing moveTo(): invalid placeId \"", "+", "placeId", "+", "\".\"", ")", ";", "return"...
Requests that this client be moved to the specified place. A request will be made and when the response is received, the location observers will be notified of success or failure. @return true if the move to request was issued, false if it was rejected by a location observer or because we have another request outstanding.
[ "Requests", "that", "this", "client", "be", "moved", "to", "the", "specified", "place", ".", "A", "request", "will", "be", "made", "and", "when", "the", "response", "is", "received", "the", "location", "observers", "will", "be", "notified", "of", "success", ...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L125-L182
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.leavePlace
public boolean leavePlace () { if (_pendingPlaceId != -1) { return false; } _lservice.leavePlace(); didLeavePlace(); // let our observers know that we're no longer in a location _observers.apply(_didChangeOp); return true; }
java
public boolean leavePlace () { if (_pendingPlaceId != -1) { return false; } _lservice.leavePlace(); didLeavePlace(); // let our observers know that we're no longer in a location _observers.apply(_didChangeOp); return true; }
[ "public", "boolean", "leavePlace", "(", ")", "{", "if", "(", "_pendingPlaceId", "!=", "-", "1", ")", "{", "return", "false", ";", "}", "_lservice", ".", "leavePlace", "(", ")", ";", "didLeavePlace", "(", ")", ";", "// let our observers know that we're no longe...
Issues a request to leave our current location. @return true if we were able to leave, false if we are in the middle of moving somewhere and can't yet leave.
[ "Issues", "a", "request", "to", "leave", "our", "current", "location", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L207-L220
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.mayMoveTo
public boolean mayMoveTo (final int placeId, ResultListener<PlaceConfig> rl) { final boolean[] vetoed = new boolean[1]; _observers.apply(new ObserverOp<LocationObserver>() { public boolean apply (LocationObserver obs) { vetoed[0] = (vetoed[0] || !obs.locationMayChange(placeId)); return true; } }); // if we're actually going somewhere, let the controller know that we might be leaving mayLeavePlace(); // if we have a result listener, let it know if we failed or keep it for later if we're // still going if (rl != null) { if (vetoed[0]) { rl.requestFailed(new MoveVetoedException()); } else { _moveListener = rl; } } // and return the result return !vetoed[0]; }
java
public boolean mayMoveTo (final int placeId, ResultListener<PlaceConfig> rl) { final boolean[] vetoed = new boolean[1]; _observers.apply(new ObserverOp<LocationObserver>() { public boolean apply (LocationObserver obs) { vetoed[0] = (vetoed[0] || !obs.locationMayChange(placeId)); return true; } }); // if we're actually going somewhere, let the controller know that we might be leaving mayLeavePlace(); // if we have a result listener, let it know if we failed or keep it for later if we're // still going if (rl != null) { if (vetoed[0]) { rl.requestFailed(new MoveVetoedException()); } else { _moveListener = rl; } } // and return the result return !vetoed[0]; }
[ "public", "boolean", "mayMoveTo", "(", "final", "int", "placeId", ",", "ResultListener", "<", "PlaceConfig", ">", "rl", ")", "{", "final", "boolean", "[", "]", "vetoed", "=", "new", "boolean", "[", "1", "]", ";", "_observers", ".", "apply", "(", "new", ...
This can be called by cooperating directors that need to coopt the moving process to extend it in some way or other. In such situations, they should call this method before moving to a new location to check to be sure that all of the registered location observers are amenable to a location change. @param placeId the place oid of our tentative new location. @return true if everyone is happy with the move, false if it was vetoed by one of the location observers.
[ "This", "can", "be", "called", "by", "cooperating", "directors", "that", "need", "to", "coopt", "the", "moving", "process", "to", "extend", "it", "in", "some", "way", "or", "other", ".", "In", "such", "situations", "they", "should", "call", "this", "method...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L233-L257
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.mayLeavePlace
protected void mayLeavePlace () { if (_controller != null) { try { _controller.mayLeavePlace(_plobj); } catch (Exception e) { log.warning("Place controller choked in mayLeavePlace", "plobj", _plobj, e); } } }
java
protected void mayLeavePlace () { if (_controller != null) { try { _controller.mayLeavePlace(_plobj); } catch (Exception e) { log.warning("Place controller choked in mayLeavePlace", "plobj", _plobj, e); } } }
[ "protected", "void", "mayLeavePlace", "(", ")", "{", "if", "(", "_controller", "!=", "null", ")", "{", "try", "{", "_controller", ".", "mayLeavePlace", "(", "_plobj", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "warning", "(", ...
Called to inform our controller that we may be leaving the current place.
[ "Called", "to", "inform", "our", "controller", "that", "we", "may", "be", "leaving", "the", "current", "place", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L262-L271
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.didMoveTo
public void didMoveTo (int placeId, PlaceConfig config) { if (_moveListener != null) { _moveListener.requestCompleted(config); _moveListener = null; } // keep track of our previous place id _previousPlaceId = _placeId; // clear out our last request time _lastRequestTime = 0; // do some cleaning up in case we were previously in a place didLeavePlace(); // make a note that we're now mostly in the new location _placeId = placeId; // start up a new place controller to manage the new place try { _controller = createController(config); if (_controller == null) { log.warning("Place config returned null controller", "config", config); return; } _controller.init(_ctx, config); // subscribe to our new place object to complete the move subscribeToPlace(); } catch (Exception e) { log.warning("Failed to create place controller", "config", config, e); handleFailure(_placeId, LocationCodes.E_INTERNAL_ERROR); } }
java
public void didMoveTo (int placeId, PlaceConfig config) { if (_moveListener != null) { _moveListener.requestCompleted(config); _moveListener = null; } // keep track of our previous place id _previousPlaceId = _placeId; // clear out our last request time _lastRequestTime = 0; // do some cleaning up in case we were previously in a place didLeavePlace(); // make a note that we're now mostly in the new location _placeId = placeId; // start up a new place controller to manage the new place try { _controller = createController(config); if (_controller == null) { log.warning("Place config returned null controller", "config", config); return; } _controller.init(_ctx, config); // subscribe to our new place object to complete the move subscribeToPlace(); } catch (Exception e) { log.warning("Failed to create place controller", "config", config, e); handleFailure(_placeId, LocationCodes.E_INTERNAL_ERROR); } }
[ "public", "void", "didMoveTo", "(", "int", "placeId", ",", "PlaceConfig", "config", ")", "{", "if", "(", "_moveListener", "!=", "null", ")", "{", "_moveListener", ".", "requestCompleted", "(", "config", ")", ";", "_moveListener", "=", "null", ";", "}", "//...
This can be called by cooperating directors that need to coopt the moving process to extend it in some way or other. In such situations, they will be responsible for receiving the successful move response and they should let the location director know that the move has been effected. @param placeId the place oid of our new location. @param config the configuration information for the new place.
[ "This", "can", "be", "called", "by", "cooperating", "directors", "that", "need", "to", "coopt", "the", "moving", "process", "to", "extend", "it", "in", "some", "way", "or", "other", ".", "In", "such", "situations", "they", "will", "be", "responsible", "for...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L282-L317
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.didLeavePlace
public void didLeavePlace () { // unsubscribe from our old place object if (_subber != null) { _subber.unsubscribe(_ctx.getDObjectManager()); _subber = null; } // let the old controller know that things are going away if (_plobj != null && _controller != null) { try { _controller.didLeavePlace(_plobj); } catch (Exception e) { log.warning("Place controller choked in didLeavePlace", "plobj", _plobj, e); } } // and clear out other bits _plobj = null; _controller = null; _placeId = -1; }
java
public void didLeavePlace () { // unsubscribe from our old place object if (_subber != null) { _subber.unsubscribe(_ctx.getDObjectManager()); _subber = null; } // let the old controller know that things are going away if (_plobj != null && _controller != null) { try { _controller.didLeavePlace(_plobj); } catch (Exception e) { log.warning("Place controller choked in didLeavePlace", "plobj", _plobj, e); } } // and clear out other bits _plobj = null; _controller = null; _placeId = -1; }
[ "public", "void", "didLeavePlace", "(", ")", "{", "// unsubscribe from our old place object", "if", "(", "_subber", "!=", "null", ")", "{", "_subber", ".", "unsubscribe", "(", "_ctx", ".", "getDObjectManager", "(", ")", ")", ";", "_subber", "=", "null", ";", ...
Called when we're leaving our current location. Informs the location's controller that we're departing, unsubscribes from the location's place object, and clears out our internal place information.
[ "Called", "when", "we", "re", "leaving", "our", "current", "location", ".", "Informs", "the", "location", "s", "controller", "that", "we", "re", "departing", "unsubscribes", "from", "the", "location", "s", "place", "object", "and", "clears", "out", "our", "i...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L324-L345
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.failedToMoveTo
public void failedToMoveTo (int placeId, String reason) { if (_moveListener != null) { _moveListener.requestFailed(new MoveFailedException(reason)); _moveListener = null; } // clear out our last request time _lastRequestTime = 0; // let our observers know what's up handleFailure(placeId, reason); }
java
public void failedToMoveTo (int placeId, String reason) { if (_moveListener != null) { _moveListener.requestFailed(new MoveFailedException(reason)); _moveListener = null; } // clear out our last request time _lastRequestTime = 0; // let our observers know what's up handleFailure(placeId, reason); }
[ "public", "void", "failedToMoveTo", "(", "int", "placeId", ",", "String", "reason", ")", "{", "if", "(", "_moveListener", "!=", "null", ")", "{", "_moveListener", ".", "requestFailed", "(", "new", "MoveFailedException", "(", "reason", ")", ")", ";", "_moveLi...
This can be called by cooperating directors that need to coopt the moving process to extend it in some way or other. If the coopted move request fails, this failure can be propagated to the location observers if appropriate. @param placeId the place oid to which we failed to move. @param reason the reason code given for failure.
[ "This", "can", "be", "called", "by", "cooperating", "directors", "that", "need", "to", "coopt", "the", "moving", "process", "to", "extend", "it", "in", "some", "way", "or", "other", ".", "If", "the", "coopted", "move", "request", "fails", "this", "failure"...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L355-L367
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.checkRepeatMove
public boolean checkRepeatMove () { long now = System.currentTimeMillis(); if (now - _lastRequestTime < STALE_REQUEST_DURATION) { return true; } else { _lastRequestTime = now; return false; } }
java
public boolean checkRepeatMove () { long now = System.currentTimeMillis(); if (now - _lastRequestTime < STALE_REQUEST_DURATION) { return true; } else { _lastRequestTime = now; return false; } }
[ "public", "boolean", "checkRepeatMove", "(", ")", "{", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "now", "-", "_lastRequestTime", "<", "STALE_REQUEST_DURATION", ")", "{", "return", "true", ";", "}", "else", "{", "_las...
Called to test and set a time stamp that we use to determine if a pending moveTo request is stale.
[ "Called", "to", "test", "and", "set", "a", "time", "stamp", "that", "we", "use", "to", "determine", "if", "a", "pending", "moveTo", "request", "is", "stale", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L373-L383
train
threerings/narya
core/src/main/java/com/threerings/crowd/client/LocationDirector.java
LocationDirector.setFailureHandler
public void setFailureHandler (FailureHandler handler) { if (_failureHandler != null) { log.warning("Requested to set failure handler, but we've already got one. The " + "conflicting entities will likely need to perform more sophisticated " + "coordination to deal with failures.", "old", _failureHandler, "new", handler); } else { _failureHandler = handler; } }
java
public void setFailureHandler (FailureHandler handler) { if (_failureHandler != null) { log.warning("Requested to set failure handler, but we've already got one. The " + "conflicting entities will likely need to perform more sophisticated " + "coordination to deal with failures.", "old", _failureHandler, "new", handler); } else { _failureHandler = handler; } }
[ "public", "void", "setFailureHandler", "(", "FailureHandler", "handler", ")", "{", "if", "(", "_failureHandler", "!=", "null", ")", "{", "log", ".", "warning", "(", "\"Requested to set failure handler, but we've already got one. The \"", "+", "\"conflicting entities will li...
Sets the failure handler which will recover from place object fetching failures. In the event that we are unable to fetch our place object after making a successful moveTo request, we attempt to rectify the failure by moving back to the last known working location. Because entites that cooperate with the location director may need to become involved in this failure recovery, we provide this interface whereby they can interject themseves into the failure recovery process and do their own failure recovery.
[ "Sets", "the", "failure", "handler", "which", "will", "recover", "from", "place", "object", "fetching", "failures", ".", "In", "the", "event", "that", "we", "are", "unable", "to", "fetch", "our", "place", "object", "after", "making", "a", "successful", "move...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/LocationDirector.java#L527-L538
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.removeGlobals
public void removeGlobals () { Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); if (name.indexOf('.') == -1) { i.remove(); } else if (name.startsWith("java.lang")) { i.remove(); } } }
java
public void removeGlobals () { Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); if (name.indexOf('.') == -1) { i.remove(); } else if (name.startsWith("java.lang")) { i.remove(); } } }
[ "public", "void", "removeGlobals", "(", ")", "{", "Iterator", "<", "String", ">", "i", "=", "_imports", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "String", "name", "=", "i", ".", "next", "(", ")", ";",...
Gets rid of primitive and java.lang imports.
[ "Gets", "rid", "of", "primitive", "and", "java", ".", "lang", "imports", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L117-L128
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.removeSamePackage
public void removeSamePackage (String pkg) { Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); if (name.startsWith(pkg) && name.indexOf('.', pkg.length() + 1) == -1) { i.remove(); } } }
java
public void removeSamePackage (String pkg) { Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); if (name.startsWith(pkg) && name.indexOf('.', pkg.length() + 1) == -1) { i.remove(); } } }
[ "public", "void", "removeSamePackage", "(", "String", "pkg", ")", "{", "Iterator", "<", "String", ">", "i", "=", "_imports", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "String", "name", "=", "i", ".", "ne...
Remove all classes that are in the same package. @param pkg package to remove
[ "Remove", "all", "classes", "that", "are", "in", "the", "same", "package", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L142-L152
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.translateClassArrays
public void translateClassArrays () { ImportSet arrayTypes = new ImportSet(); Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); int bracket = name.lastIndexOf('['); if (bracket != -1 && name.charAt(bracket + 1) == 'L') { arrayTypes.add(name.substring(bracket + 2, name.length() - 1)); } } addAll(arrayTypes); }
java
public void translateClassArrays () { ImportSet arrayTypes = new ImportSet(); Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); int bracket = name.lastIndexOf('['); if (bracket != -1 && name.charAt(bracket + 1) == 'L') { arrayTypes.add(name.substring(bracket + 2, name.length() - 1)); } } addAll(arrayTypes); }
[ "public", "void", "translateClassArrays", "(", ")", "{", "ImportSet", "arrayTypes", "=", "new", "ImportSet", "(", ")", ";", "Iterator", "<", "String", ">", "i", "=", "_imports", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")...
Inserts imports for the non-primitive classes contained in all array imports.
[ "Inserts", "imports", "for", "the", "non", "-", "primitive", "classes", "contained", "in", "all", "array", "imports", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L196-L210
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.popIn
public void popIn () { String front = _pushed.remove(_pushed.size() - 1); if (front != null) { _imports.add(front); } }
java
public void popIn () { String front = _pushed.remove(_pushed.size() - 1); if (front != null) { _imports.add(front); } }
[ "public", "void", "popIn", "(", ")", "{", "String", "front", "=", "_pushed", ".", "remove", "(", "_pushed", ".", "size", "(", ")", "-", "1", ")", ";", "if", "(", "front", "!=", "null", ")", "{", "_imports", ".", "add", "(", "front", ")", ";", "...
Re-adds the most recently popped import to the set. If a null value was pushed, does nothing. @throws IndexOutOfBoundsException if there is nothing to pop
[ "Re", "-", "adds", "the", "most", "recently", "popped", "import", "to", "the", "set", ".", "If", "a", "null", "value", "was", "pushed", "does", "nothing", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L238-L244
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.replace
public void replace (String... replace) { HashSet<String> toAdd = Sets.newHashSet(); Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); for (int j = 0; j < replace.length; j += 2) { if (name.equals(replace[j])) { toAdd.add(replace[j + 1]); i.remove(); break; } } } _imports.addAll(toAdd); }
java
public void replace (String... replace) { HashSet<String> toAdd = Sets.newHashSet(); Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); for (int j = 0; j < replace.length; j += 2) { if (name.equals(replace[j])) { toAdd.add(replace[j + 1]); i.remove(); break; } } } _imports.addAll(toAdd); }
[ "public", "void", "replace", "(", "String", "...", "replace", ")", "{", "HashSet", "<", "String", ">", "toAdd", "=", "Sets", ".", "newHashSet", "(", ")", ";", "Iterator", "<", "String", ">", "i", "=", "_imports", ".", "iterator", "(", ")", ";", "whil...
Replaces any import exactly each find string with the corresponding replace string. See the description above. @param replace array of pairs for search/replace
[ "Replaces", "any", "import", "exactly", "each", "find", "string", "with", "the", "corresponding", "replace", "string", ".", "See", "the", "description", "above", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L265-L280
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.removeAll
public int removeAll (String pattern) { Pattern pat = makePattern(pattern); int removed = 0; Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); if (pat.matcher(name).matches()) { i.remove(); ++removed; } } return removed; }
java
public int removeAll (String pattern) { Pattern pat = makePattern(pattern); int removed = 0; Iterator<String> i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); if (pat.matcher(name).matches()) { i.remove(); ++removed; } } return removed; }
[ "public", "int", "removeAll", "(", "String", "pattern", ")", "{", "Pattern", "pat", "=", "makePattern", "(", "pattern", ")", ";", "int", "removed", "=", "0", ";", "Iterator", "<", "String", ">", "i", "=", "_imports", ".", "iterator", "(", ")", ";", "...
Remove all imports matching the given pattern. @param pattern the dumbed down regex to match (see description above) @return the number of imports removed
[ "Remove", "all", "imports", "matching", "the", "given", "pattern", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L297-L310
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.toGroups
public List<List<String>> toGroups () { List<String> list = Lists.newArrayList(_imports); Collections.sort(list, new Comparator<String>() { public int compare (String class1, String class2) { return ComparisonChain.start() .compare(findImportGroup(class1), findImportGroup(class2)) .compare(class1, class2) .result(); } }); List<List<String>> result = Lists.newArrayList(); List<String> current = null; int lastGroup = -2; for (String imp : list) { int group = findImportGroup(imp); if (group != lastGroup) { if (current == null || !current.isEmpty()) { result.add(current = Lists.<String>newArrayList()); } lastGroup = group; } current.add(imp); } return result; }
java
public List<List<String>> toGroups () { List<String> list = Lists.newArrayList(_imports); Collections.sort(list, new Comparator<String>() { public int compare (String class1, String class2) { return ComparisonChain.start() .compare(findImportGroup(class1), findImportGroup(class2)) .compare(class1, class2) .result(); } }); List<List<String>> result = Lists.newArrayList(); List<String> current = null; int lastGroup = -2; for (String imp : list) { int group = findImportGroup(imp); if (group != lastGroup) { if (current == null || !current.isEmpty()) { result.add(current = Lists.<String>newArrayList()); } lastGroup = group; } current.add(imp); } return result; }
[ "public", "List", "<", "List", "<", "String", ">", ">", "toGroups", "(", ")", "{", "List", "<", "String", ">", "list", "=", "Lists", ".", "newArrayList", "(", "_imports", ")", ";", "Collections", ".", "sort", "(", "list", ",", "new", "Comparator", "<...
Converts the set of imports to groups of class names, according to conventional package ordering and spacing. Within each group, sorting is alphabetical.
[ "Converts", "the", "set", "of", "imports", "to", "groups", "of", "class", "names", "according", "to", "conventional", "package", "ordering", "and", "spacing", ".", "Within", "each", "group", "sorting", "is", "alphabetical", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L341-L366
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.toList
public List<String> toList () { ComparableArrayList<String> list = new ComparableArrayList<String>(); list.addAll(_imports); list.sort(); return list; }
java
public List<String> toList () { ComparableArrayList<String> list = new ComparableArrayList<String>(); list.addAll(_imports); list.sort(); return list; }
[ "public", "List", "<", "String", ">", "toList", "(", ")", "{", "ComparableArrayList", "<", "String", ">", "list", "=", "new", "ComparableArrayList", "<", "String", ">", "(", ")", ";", "list", ".", "addAll", "(", "_imports", ")", ";", "list", ".", "sort...
Convert the set of imports to a sorted list, ready to be output to a generated file. @return the sorted list of imports
[ "Convert", "the", "set", "of", "imports", "to", "a", "sorted", "list", "ready", "to", "be", "output", "to", "a", "generated", "file", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L372-L378
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.findImportGroup
protected int findImportGroup (String imp) { int bestGroup = -1; int bestPrefixLength = -1; int ii = -1; for (String prefix : getImportGroups()) { ii++; if (!imp.startsWith(prefix)) { continue; } if (prefix.length() > bestPrefixLength) { bestPrefixLength = prefix.length(); bestGroup = ii; } } return bestGroup; }
java
protected int findImportGroup (String imp) { int bestGroup = -1; int bestPrefixLength = -1; int ii = -1; for (String prefix : getImportGroups()) { ii++; if (!imp.startsWith(prefix)) { continue; } if (prefix.length() > bestPrefixLength) { bestPrefixLength = prefix.length(); bestGroup = ii; } } return bestGroup; }
[ "protected", "int", "findImportGroup", "(", "String", "imp", ")", "{", "int", "bestGroup", "=", "-", "1", ";", "int", "bestPrefixLength", "=", "-", "1", ";", "int", "ii", "=", "-", "1", ";", "for", "(", "String", "prefix", ":", "getImportGroups", "(", ...
Find the index of the best import group to use for the specified import.
[ "Find", "the", "index", "of", "the", "best", "import", "group", "to", "use", "for", "the", "specified", "import", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L389-L405
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/ImportSet.java
ImportSet.makePattern
protected static Pattern makePattern (String input) { StringBuilder pattern = new StringBuilder('^'); while (true) { String[] parts = _splitter.split(input, 2); pattern.append(Pattern.quote(parts[0])); if (parts.length == 1) { break; } int length = parts[0].length(); String wildcard = input.substring(length, length + 1); if (wildcard.equals("*")) { pattern.append(".*"); } else { System.err.println("Bad wildcard " + wildcard); } input = parts[1]; } pattern.append("$"); return Pattern.compile(pattern.toString()); }
java
protected static Pattern makePattern (String input) { StringBuilder pattern = new StringBuilder('^'); while (true) { String[] parts = _splitter.split(input, 2); pattern.append(Pattern.quote(parts[0])); if (parts.length == 1) { break; } int length = parts[0].length(); String wildcard = input.substring(length, length + 1); if (wildcard.equals("*")) { pattern.append(".*"); } else { System.err.println("Bad wildcard " + wildcard); } input = parts[1]; } pattern.append("$"); return Pattern.compile(pattern.toString()); }
[ "protected", "static", "Pattern", "makePattern", "(", "String", "input", ")", "{", "StringBuilder", "pattern", "=", "new", "StringBuilder", "(", "'", "'", ")", ";", "while", "(", "true", ")", "{", "String", "[", "]", "parts", "=", "_splitter", ".", "spli...
Create a real regular expression from the dumbed down input. @param input the dumbed down wildcard expression @return the calculated regular expression
[ "Create", "a", "real", "regular", "expression", "from", "the", "dumbed", "down", "input", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/ImportSet.java#L420-L442
train
threerings/narya
core/src/main/java/com/threerings/presents/util/ClassUtil.java
ClassUtil.getMethod
public static Method getMethod (String name, Object target, Map<String, Method> cache) { Class<?> tclass = target.getClass(); String key = tclass.getName() + ":" + name; Method method = cache.get(key); if (method == null) { method = findMethod(tclass, name); if (method != null) { cache.put(key, method); } } return method; }
java
public static Method getMethod (String name, Object target, Map<String, Method> cache) { Class<?> tclass = target.getClass(); String key = tclass.getName() + ":" + name; Method method = cache.get(key); if (method == null) { method = findMethod(tclass, name); if (method != null) { cache.put(key, method); } } return method; }
[ "public", "static", "Method", "getMethod", "(", "String", "name", ",", "Object", "target", ",", "Map", "<", "String", ",", "Method", ">", "cache", ")", "{", "Class", "<", "?", ">", "tclass", "=", "target", ".", "getClass", "(", ")", ";", "String", "k...
Locates and returns the first method in the supplied class whose name is equal to the specified name. If a method is located, it will be cached in the supplied cache so that subsequent requests will immediately return the method from the cache rather than re-reflecting. @return the method with the specified name or null if no method with that name could be found.
[ "Locates", "and", "returns", "the", "first", "method", "in", "the", "supplied", "class", "whose", "name", "is", "equal", "to", "the", "specified", "name", ".", "If", "a", "method", "is", "located", "it", "will", "be", "cached", "in", "the", "supplied", "...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/ClassUtil.java#L46-L60
train
threerings/narya
core/src/main/java/com/threerings/presents/util/ClassUtil.java
ClassUtil.getMethod
public static Method getMethod (String name, Object target, Object[] args) { Class<?> tclass = target.getClass(); Method meth = null; try { MethodFinder finder = new MethodFinder(tclass); meth = finder.findMethod(name, args); } catch (NoSuchMethodException nsme) { // nothing to do here but fall through and return null log.info("No such method", "name", name, "tclass", tclass.getName(), "args", args, "error", nsme); } catch (SecurityException se) { log.warning("Unable to look up method?", "tclass", tclass.getName(), "mname", name); } return meth; }
java
public static Method getMethod (String name, Object target, Object[] args) { Class<?> tclass = target.getClass(); Method meth = null; try { MethodFinder finder = new MethodFinder(tclass); meth = finder.findMethod(name, args); } catch (NoSuchMethodException nsme) { // nothing to do here but fall through and return null log.info("No such method", "name", name, "tclass", tclass.getName(), "args", args, "error", nsme); } catch (SecurityException se) { log.warning("Unable to look up method?", "tclass", tclass.getName(), "mname", name); } return meth; }
[ "public", "static", "Method", "getMethod", "(", "String", "name", ",", "Object", "target", ",", "Object", "[", "]", "args", ")", "{", "Class", "<", "?", ">", "tclass", "=", "target", ".", "getClass", "(", ")", ";", "Method", "meth", "=", "null", ";",...
Looks up the method on the specified object that has a signature that matches the supplied arguments array. This is very expensive, so you shouldn't be doing this for something that happens frequently. @return the best matching method with the specified name that accepts the supplied arguments, or null if no method could be found. @see MethodFinder
[ "Looks", "up", "the", "method", "on", "the", "specified", "object", "that", "has", "a", "signature", "that", "matches", "the", "supplied", "arguments", "array", ".", "This", "is", "very", "expensive", "so", "you", "shouldn", "t", "be", "doing", "this", "fo...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/ClassUtil.java#L72-L91
train
threerings/narya
core/src/main/java/com/threerings/presents/util/ClassUtil.java
ClassUtil.findMethod
public static Method findMethod (Class<?> clazz, String name) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(name)) { return method; } } return null; }
java
public static Method findMethod (Class<?> clazz, String name) { Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(name)) { return method; } } return null; }
[ "public", "static", "Method", "findMethod", "(", "Class", "<", "?", ">", "clazz", ",", "String", "name", ")", "{", "Method", "[", "]", "methods", "=", "clazz", ".", "getMethods", "(", ")", ";", "for", "(", "Method", "method", ":", "methods", ")", "{"...
Locates and returns the first method in the supplied class whose name is equal to the specified name. @return the method with the specified name or null if no method with that name could be found.
[ "Locates", "and", "returns", "the", "first", "method", "in", "the", "supplied", "class", "whose", "name", "is", "equal", "to", "the", "specified", "name", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/ClassUtil.java#L100-L109
train
threerings/narya
core/src/main/java/com/threerings/presents/server/Authenticator.java
Authenticator.authenticateConnection
public void authenticateConnection (Invoker invoker, final AuthingConnection conn, final ResultListener<AuthingConnection> onComplete) { final AuthRequest req = conn.getAuthRequest(); final AuthResponseData rdata = createResponseData(); final AuthResponse rsp = new AuthResponse(rdata); invoker.postUnit(new Invoker.Unit("authenticateConnection") { @Override public boolean invoke () { try { processAuthentication(conn, rsp); if (AuthResponseData.SUCCESS.equals(rdata.code) && conn.getAuthName() == null) { // fail early, fail (less) often throw new IllegalStateException("Authenticator failed to provide authname"); } } catch (AuthException e) { rdata.code = e.getMessage(); } catch (Exception e) { log.warning("Error authenticating user", "areq", req, e); rdata.code = AuthCodes.SERVER_ERROR; } return true; } @Override public void handleResult () { // stuff a reference to the auth response into the connection so that we have // access to it later in the authentication process conn.setAuthResponse(rsp); // send the response back to the client conn.postMessage(rsp); // if the authentication request was granted, let the connection manager know that // we just authed if (AuthResponseData.SUCCESS.equals(rdata.code)) { onComplete.requestCompleted(conn); } } }); }
java
public void authenticateConnection (Invoker invoker, final AuthingConnection conn, final ResultListener<AuthingConnection> onComplete) { final AuthRequest req = conn.getAuthRequest(); final AuthResponseData rdata = createResponseData(); final AuthResponse rsp = new AuthResponse(rdata); invoker.postUnit(new Invoker.Unit("authenticateConnection") { @Override public boolean invoke () { try { processAuthentication(conn, rsp); if (AuthResponseData.SUCCESS.equals(rdata.code) && conn.getAuthName() == null) { // fail early, fail (less) often throw new IllegalStateException("Authenticator failed to provide authname"); } } catch (AuthException e) { rdata.code = e.getMessage(); } catch (Exception e) { log.warning("Error authenticating user", "areq", req, e); rdata.code = AuthCodes.SERVER_ERROR; } return true; } @Override public void handleResult () { // stuff a reference to the auth response into the connection so that we have // access to it later in the authentication process conn.setAuthResponse(rsp); // send the response back to the client conn.postMessage(rsp); // if the authentication request was granted, let the connection manager know that // we just authed if (AuthResponseData.SUCCESS.equals(rdata.code)) { onComplete.requestCompleted(conn); } } }); }
[ "public", "void", "authenticateConnection", "(", "Invoker", "invoker", ",", "final", "AuthingConnection", "conn", ",", "final", "ResultListener", "<", "AuthingConnection", ">", "onComplete", ")", "{", "final", "AuthRequest", "req", "=", "conn", ".", "getAuthRequest"...
Called by the connection management code when an authenticating connection has received its authentication request from the client.
[ "Called", "by", "the", "connection", "management", "code", "when", "an", "authenticating", "connection", "has", "received", "its", "authentication", "request", "from", "the", "client", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/Authenticator.java#L57-L98
train
xbib/marc
src/main/java/org/xbib/marc/io/ScanBuffer.java
ScanBuffer.append
public int append(int newByte) { int old = buffer2[pos]; buffer2[pos] = newByte; buffer[pos] = cs ? (char) newByte : Character.toLowerCase((char) newByte); pos = (++pos < buffer.length) ? pos : 0; return old; }
java
public int append(int newByte) { int old = buffer2[pos]; buffer2[pos] = newByte; buffer[pos] = cs ? (char) newByte : Character.toLowerCase((char) newByte); pos = (++pos < buffer.length) ? pos : 0; return old; }
[ "public", "int", "append", "(", "int", "newByte", ")", "{", "int", "old", "=", "buffer2", "[", "pos", "]", ";", "buffer2", "[", "pos", "]", "=", "newByte", ";", "buffer", "[", "pos", "]", "=", "cs", "?", "(", "char", ")", "newByte", ":", "Charact...
Append byte. @param newByte the byte @return old byte
[ "Append", "byte", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/io/ScanBuffer.java#L101-L107
train
xbib/marc
src/main/java/org/xbib/marc/io/ScanBuffer.java
ScanBuffer.hasData
public boolean hasData() { int apos = token.length - 1; int rpos = pos - 1; for (; rpos > -1 && apos > -1; rpos--, apos--) { if (buffer2[rpos] != -1) { return true; } } for (rpos = buffer2.length - 1; apos > -1; rpos--, apos--) { if (buffer2[rpos] != -1) { return true; } } return false; }
java
public boolean hasData() { int apos = token.length - 1; int rpos = pos - 1; for (; rpos > -1 && apos > -1; rpos--, apos--) { if (buffer2[rpos] != -1) { return true; } } for (rpos = buffer2.length - 1; apos > -1; rpos--, apos--) { if (buffer2[rpos] != -1) { return true; } } return false; }
[ "public", "boolean", "hasData", "(", ")", "{", "int", "apos", "=", "token", ".", "length", "-", "1", ";", "int", "rpos", "=", "pos", "-", "1", ";", "for", "(", ";", "rpos", ">", "-", "1", "&&", "apos", ">", "-", "1", ";", "rpos", "--", ",", ...
Has scan buffer any data? @return true if it has data
[ "Has", "scan", "buffer", "any", "data?" ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/io/ScanBuffer.java#L139-L153
train
xbib/marc
src/main/java/org/xbib/marc/io/ScanBuffer.java
ScanBuffer.clear
public void clear(int i) { char ch = (char) -1; int apos = i - 1; int rpos = pos - 1; for (; rpos > -1 && apos > -1; rpos--, apos--) { buffer[rpos] = ch; buffer2[rpos] = -1; } for (rpos = buffer.length - 1; apos > -1; rpos--, apos--) { buffer[rpos] = ch; buffer2[rpos] = -1; } }
java
public void clear(int i) { char ch = (char) -1; int apos = i - 1; int rpos = pos - 1; for (; rpos > -1 && apos > -1; rpos--, apos--) { buffer[rpos] = ch; buffer2[rpos] = -1; } for (rpos = buffer.length - 1; apos > -1; rpos--, apos--) { buffer[rpos] = ch; buffer2[rpos] = -1; } }
[ "public", "void", "clear", "(", "int", "i", ")", "{", "char", "ch", "=", "(", "char", ")", "-", "1", ";", "int", "apos", "=", "i", "-", "1", ";", "int", "rpos", "=", "pos", "-", "1", ";", "for", "(", ";", "rpos", ">", "-", "1", "&&", "apo...
Clear scan buffer at position. @param i the position
[ "Clear", "scan", "buffer", "at", "position", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/io/ScanBuffer.java#L159-L171
train
threerings/narya
core/src/main/java/com/threerings/crowd/data/LocationMarshaller.java
LocationMarshaller.moveTo
public void moveTo (int arg1, LocationService.MoveListener arg2) { LocationMarshaller.MoveMarshaller listener2 = new LocationMarshaller.MoveMarshaller(); listener2.listener = arg2; sendRequest(MOVE_TO, new Object[] { Integer.valueOf(arg1), listener2 }); }
java
public void moveTo (int arg1, LocationService.MoveListener arg2) { LocationMarshaller.MoveMarshaller listener2 = new LocationMarshaller.MoveMarshaller(); listener2.listener = arg2; sendRequest(MOVE_TO, new Object[] { Integer.valueOf(arg1), listener2 }); }
[ "public", "void", "moveTo", "(", "int", "arg1", ",", "LocationService", ".", "MoveListener", "arg2", ")", "{", "LocationMarshaller", ".", "MoveMarshaller", "listener2", "=", "new", "LocationMarshaller", ".", "MoveMarshaller", "(", ")", ";", "listener2", ".", "li...
from interface LocationService
[ "from", "interface", "LocationService" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/data/LocationMarshaller.java#L89-L96
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/server/SpeakHandler.java
SpeakHandler.speak
public void speak (ClientObject caller, String message, byte mode) { // ensure that the caller has normal chat privileges BodyObject source = (_locator != null) ? _locator.forClient(caller) : (BodyObject) caller; String errmsg = source.checkAccess(ChatCodes.CHAT_ACCESS, null); if (errmsg != null) { // we normally don't listen for responses to speak messages so we can't just throw an // InvocationException, we have to specifically communicate the error to the user SpeakUtil.sendFeedback(source, MessageManager.GLOBAL_BUNDLE, errmsg); return; } // TODO: broadcast should be handled more like a system message rather than as a mode for a // user message so that we don't have to do this validation here. Or not. // ensure that the speaker is valid if ((mode == ChatCodes.BROADCAST_MODE) || (_validator != null && !_validator.isValidSpeaker(_speakObj, source, mode))) { log.warning("Refusing invalid speak request", "source", source.who(), "speakObj", _speakObj.which(), "message", message, "mode", mode); } else { // issue the speak message on our speak object sendSpeak(source, message, mode); } }
java
public void speak (ClientObject caller, String message, byte mode) { // ensure that the caller has normal chat privileges BodyObject source = (_locator != null) ? _locator.forClient(caller) : (BodyObject) caller; String errmsg = source.checkAccess(ChatCodes.CHAT_ACCESS, null); if (errmsg != null) { // we normally don't listen for responses to speak messages so we can't just throw an // InvocationException, we have to specifically communicate the error to the user SpeakUtil.sendFeedback(source, MessageManager.GLOBAL_BUNDLE, errmsg); return; } // TODO: broadcast should be handled more like a system message rather than as a mode for a // user message so that we don't have to do this validation here. Or not. // ensure that the speaker is valid if ((mode == ChatCodes.BROADCAST_MODE) || (_validator != null && !_validator.isValidSpeaker(_speakObj, source, mode))) { log.warning("Refusing invalid speak request", "source", source.who(), "speakObj", _speakObj.which(), "message", message, "mode", mode); } else { // issue the speak message on our speak object sendSpeak(source, message, mode); } }
[ "public", "void", "speak", "(", "ClientObject", "caller", ",", "String", "message", ",", "byte", "mode", ")", "{", "// ensure that the caller has normal chat privileges", "BodyObject", "source", "=", "(", "_locator", "!=", "null", ")", "?", "_locator", ".", "forCl...
from interface SpeakProvider
[ "from", "interface", "SpeakProvider" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakHandler.java#L87-L114
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/server/SpeakHandler.java
SpeakHandler.sendSpeak
protected void sendSpeak (BodyObject source, String message, byte mode) { SpeakUtil.sendSpeak(_speakObj, source.getVisibleName(), null, message, mode); }
java
protected void sendSpeak (BodyObject source, String message, byte mode) { SpeakUtil.sendSpeak(_speakObj, source.getVisibleName(), null, message, mode); }
[ "protected", "void", "sendSpeak", "(", "BodyObject", "source", ",", "String", "message", ",", "byte", "mode", ")", "{", "SpeakUtil", ".", "sendSpeak", "(", "_speakObj", ",", "source", ".", "getVisibleName", "(", ")", ",", "null", ",", "message", ",", "mode...
Sends the actual speak message.
[ "Sends", "the", "actual", "speak", "message", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakHandler.java#L119-L122
train
dkpro/dkpro-argumentation
dkpro-argumentation-preprocessing/src/main/java/org/dkpro/argumentation/preprocessing/annotation/ArgumentSimplifiedTokenBIOAnnotator.java
ArgumentSimplifiedTokenBIOAnnotator.selectMainArgumentComponent
protected ArgumentComponent selectMainArgumentComponent( List<ArgumentComponent> argumentComponents) { ArgumentComponent result = null; int maxLength = Integer.MIN_VALUE; for (ArgumentComponent argumentComponent : argumentComponents) { int length = argumentComponent.getEnd() - argumentComponent.getBegin(); if (length > maxLength) { maxLength = length; result = argumentComponent; } } if (result == null) { throw new IllegalStateException("Couldn't find maximum arg. component"); } return result; }
java
protected ArgumentComponent selectMainArgumentComponent( List<ArgumentComponent> argumentComponents) { ArgumentComponent result = null; int maxLength = Integer.MIN_VALUE; for (ArgumentComponent argumentComponent : argumentComponents) { int length = argumentComponent.getEnd() - argumentComponent.getBegin(); if (length > maxLength) { maxLength = length; result = argumentComponent; } } if (result == null) { throw new IllegalStateException("Couldn't find maximum arg. component"); } return result; }
[ "protected", "ArgumentComponent", "selectMainArgumentComponent", "(", "List", "<", "ArgumentComponent", ">", "argumentComponents", ")", "{", "ArgumentComponent", "result", "=", "null", ";", "int", "maxLength", "=", "Integer", ".", "MIN_VALUE", ";", "for", "(", "Argu...
Selects the main argument component from a list of components that are present in the sentence; currently the longest @param argumentComponents list of argument components @return argument component
[ "Selects", "the", "main", "argument", "component", "from", "a", "list", "of", "components", "that", "are", "present", "in", "the", "sentence", ";", "currently", "the", "longest" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-preprocessing/src/main/java/org/dkpro/argumentation/preprocessing/annotation/ArgumentSimplifiedTokenBIOAnnotator.java#L236-L256
train
threerings/narya
core/src/main/java/com/threerings/presents/server/InvocationException.java
InvocationException.requireAccess
public static void requireAccess (ClientObject clobj, Permission perm, Object context) throws InvocationException { String errmsg = clobj.checkAccess(perm, context); if (errmsg != null) { throw new InvocationException(errmsg); } }
java
public static void requireAccess (ClientObject clobj, Permission perm, Object context) throws InvocationException { String errmsg = clobj.checkAccess(perm, context); if (errmsg != null) { throw new InvocationException(errmsg); } }
[ "public", "static", "void", "requireAccess", "(", "ClientObject", "clobj", ",", "Permission", "perm", ",", "Object", "context", ")", "throws", "InvocationException", "{", "String", "errmsg", "=", "clobj", ".", "checkAccess", "(", "perm", ",", "context", ")", "...
Requires that the specified client have the specified permissions. @throws InvocationException if they do not.
[ "Requires", "that", "the", "specified", "client", "have", "the", "specified", "permissions", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/InvocationException.java#L39-L46
train
threerings/narya
core/src/main/java/com/threerings/io/ArrayMask.java
ArrayMask.writeTo
public void writeTo (ObjectOutputStream out) throws IOException { out.writeShort(_mask.length); out.write(_mask); }
java
public void writeTo (ObjectOutputStream out) throws IOException { out.writeShort(_mask.length); out.write(_mask); }
[ "public", "void", "writeTo", "(", "ObjectOutputStream", "out", ")", "throws", "IOException", "{", "out", ".", "writeShort", "(", "_mask", ".", "length", ")", ";", "out", ".", "write", "(", "_mask", ")", ";", "}" ]
Writes this mask to the specified output stream.
[ "Writes", "this", "mask", "to", "the", "specified", "output", "stream", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ArrayMask.java#L71-L76
train
threerings/narya
core/src/main/java/com/threerings/io/ArrayMask.java
ArrayMask.readFrom
public void readFrom (ObjectInputStream in) throws IOException { int length = in.readShort(); _mask = new byte[length]; in.read(_mask); }
java
public void readFrom (ObjectInputStream in) throws IOException { int length = in.readShort(); _mask = new byte[length]; in.read(_mask); }
[ "public", "void", "readFrom", "(", "ObjectInputStream", "in", ")", "throws", "IOException", "{", "int", "length", "=", "in", ".", "readShort", "(", ")", ";", "_mask", "=", "new", "byte", "[", "length", "]", ";", "in", ".", "read", "(", "_mask", ")", ...
Reads this mask from the specified input stream.
[ "Reads", "this", "mask", "from", "the", "specified", "input", "stream", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ArrayMask.java#L81-L87
train
threerings/narya
core/src/main/java/com/threerings/nio/conman/Connection.java
Connection.init
public void init (ConnectionManager cmgr, SocketChannel channel, long createStamp) throws IOException { _cmgr = cmgr; _channel = channel; _lastEvent = createStamp; _connectionId = ++_lastConnectionId; }
java
public void init (ConnectionManager cmgr, SocketChannel channel, long createStamp) throws IOException { _cmgr = cmgr; _channel = channel; _lastEvent = createStamp; _connectionId = ++_lastConnectionId; }
[ "public", "void", "init", "(", "ConnectionManager", "cmgr", ",", "SocketChannel", "channel", ",", "long", "createStamp", ")", "throws", "IOException", "{", "_cmgr", "=", "cmgr", ";", "_channel", "=", "channel", ";", "_lastEvent", "=", "createStamp", ";", "_con...
Initializes a connection object with a socket and related info. @param cmgr The connection manager with which this connection is associated. @param channel The socket channel from which we'll be reading messages. @param createStamp The time at which this connection was created.
[ "Initializes", "a", "connection", "object", "with", "a", "socket", "and", "related", "info", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/nio/conman/Connection.java#L47-L54
train
threerings/narya
core/src/main/java/com/threerings/nio/conman/Connection.java
Connection.networkFailure
public void networkFailure (IOException ioe) { // if we're already closed, then something is seriously funny if (isClosed()) { log.warning("Failure reported on closed connection " + this + ".", new Exception()); return; } // let the connection manager know we're hosed _cmgr.connectionFailed(this, ioe); // and close our socket closeSocket(); }
java
public void networkFailure (IOException ioe) { // if we're already closed, then something is seriously funny if (isClosed()) { log.warning("Failure reported on closed connection " + this + ".", new Exception()); return; } // let the connection manager know we're hosed _cmgr.connectionFailed(this, ioe); // and close our socket closeSocket(); }
[ "public", "void", "networkFailure", "(", "IOException", "ioe", ")", "{", "// if we're already closed, then something is seriously funny", "if", "(", "isClosed", "(", ")", ")", "{", "log", ".", "warning", "(", "\"Failure reported on closed connection \"", "+", "this", "+...
Called when there is a failure reading or writing to this connection. We notify the connection manager and close ourselves down.
[ "Called", "when", "there", "is", "a", "failure", "reading", "or", "writing", "to", "this", "connection", ".", "We", "notify", "the", "connection", "manager", "and", "close", "ourselves", "down", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/nio/conman/Connection.java#L131-L144
train
threerings/narya
core/src/main/java/com/threerings/nio/conman/Connection.java
Connection.checkIdle
public boolean checkIdle (long idleStamp) { if (_lastEvent > idleStamp) { return false; } if (!isClosed()) { log.info("Disconnecting non-communicative client", "conn", this, "idle", (System.currentTimeMillis() - _lastEvent) + "ms"); } return true; }
java
public boolean checkIdle (long idleStamp) { if (_lastEvent > idleStamp) { return false; } if (!isClosed()) { log.info("Disconnecting non-communicative client", "conn", this, "idle", (System.currentTimeMillis() - _lastEvent) + "ms"); } return true; }
[ "public", "boolean", "checkIdle", "(", "long", "idleStamp", ")", "{", "if", "(", "_lastEvent", ">", "idleStamp", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isClosed", "(", ")", ")", "{", "log", ".", "info", "(", "\"Disconnecting non-communic...
from interface NetEventHandler
[ "from", "interface", "NetEventHandler" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/nio/conman/Connection.java#L147-L157
train
threerings/narya
core/src/main/java/com/threerings/nio/conman/Connection.java
Connection.closeSocket
protected void closeSocket () { if (_channel == null) { return; } log.debug("Closing channel " + this + "."); try { _channel.close(); } catch (IOException ioe) { log.warning("Error closing connection", "conn", this, "error", ioe); } // clear out our references to prevent repeat closings _channel = null; }
java
protected void closeSocket () { if (_channel == null) { return; } log.debug("Closing channel " + this + "."); try { _channel.close(); } catch (IOException ioe) { log.warning("Error closing connection", "conn", this, "error", ioe); } // clear out our references to prevent repeat closings _channel = null; }
[ "protected", "void", "closeSocket", "(", ")", "{", "if", "(", "_channel", "==", "null", ")", "{", "return", ";", "}", "log", ".", "debug", "(", "\"Closing channel \"", "+", "this", "+", "\".\"", ")", ";", "try", "{", "_channel", ".", "close", "(", ")...
Closes the socket associated with this connection. This happens when we receive EOF, are requested to close down or when our connection fails.
[ "Closes", "the", "socket", "associated", "with", "this", "connection", ".", "This", "happens", "when", "we", "receive", "EOF", "are", "requested", "to", "close", "down", "or", "when", "our", "connection", "fails", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/nio/conman/Connection.java#L175-L190
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.checkToken
public String checkToken (BureauCredentials creds) { Bureau bureau = _bureaus.get(creds.clientId); if (bureau == null) { return "Bureau " + creds.clientId + " not found"; } if (bureau.clientObj != null) { return "Bureau " + creds.clientId + " already logged in"; } if (!creds.areValid(bureau.token)) { return "Bureau " + creds.clientId + " does not match credentials token"; } return null; }
java
public String checkToken (BureauCredentials creds) { Bureau bureau = _bureaus.get(creds.clientId); if (bureau == null) { return "Bureau " + creds.clientId + " not found"; } if (bureau.clientObj != null) { return "Bureau " + creds.clientId + " already logged in"; } if (!creds.areValid(bureau.token)) { return "Bureau " + creds.clientId + " does not match credentials token"; } return null; }
[ "public", "String", "checkToken", "(", "BureauCredentials", "creds", ")", "{", "Bureau", "bureau", "=", "_bureaus", ".", "get", "(", "creds", ".", "clientId", ")", ";", "if", "(", "bureau", "==", "null", ")", "{", "return", "\"Bureau \"", "+", "creds", "...
Check the credentials to make sure this is one of our bureaus. @return null if all's well, otherwise a string describing the authentication failure
[ "Check", "the", "credentials", "to", "make", "sure", "this", "is", "one", "of", "our", "bureaus", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L150-L163
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.startAgent
public void startAgent (AgentObject agent) { agent.setLocal(AgentData.class, new AgentData()); Bureau bureau = _bureaus.get(agent.bureauId); if (bureau != null && bureau.ready()) { _omgr.registerObject(agent); log.info("Bureau ready, sending createAgent", "agent", agent.which()); BureauSender.createAgent(bureau.clientObj, agent.getOid()); bureau.agentStates.put(agent, AgentState.STARTED); bureau.summarize(); return; } if (bureau == null) { LauncherEntry launcherEntry = _launchers.get(agent.bureauType); if (launcherEntry == null) { log.warning("Launcher not found", "agent", agent.which()); return; } log.info("Creating new bureau", "bureauId", agent.bureauId, "launcher", launcherEntry); bureau = new Bureau(); bureau.bureauId = agent.bureauId; bureau.token = generateToken(bureau.bureauId); bureau.launcherEntry = launcherEntry; _invoker.postUnit(new LauncherUnit(bureau, _omgr)); _bureaus.put(agent.bureauId, bureau); } _omgr.registerObject(agent); bureau.agentStates.put(agent, AgentState.PENDING); log.info("Bureau not ready, pending agent", "agent", agent.which()); bureau.summarize(); }
java
public void startAgent (AgentObject agent) { agent.setLocal(AgentData.class, new AgentData()); Bureau bureau = _bureaus.get(agent.bureauId); if (bureau != null && bureau.ready()) { _omgr.registerObject(agent); log.info("Bureau ready, sending createAgent", "agent", agent.which()); BureauSender.createAgent(bureau.clientObj, agent.getOid()); bureau.agentStates.put(agent, AgentState.STARTED); bureau.summarize(); return; } if (bureau == null) { LauncherEntry launcherEntry = _launchers.get(agent.bureauType); if (launcherEntry == null) { log.warning("Launcher not found", "agent", agent.which()); return; } log.info("Creating new bureau", "bureauId", agent.bureauId, "launcher", launcherEntry); bureau = new Bureau(); bureau.bureauId = agent.bureauId; bureau.token = generateToken(bureau.bureauId); bureau.launcherEntry = launcherEntry; _invoker.postUnit(new LauncherUnit(bureau, _omgr)); _bureaus.put(agent.bureauId, bureau); } _omgr.registerObject(agent); bureau.agentStates.put(agent, AgentState.PENDING); log.info("Bureau not ready, pending agent", "agent", agent.which()); bureau.summarize(); }
[ "public", "void", "startAgent", "(", "AgentObject", "agent", ")", "{", "agent", ".", "setLocal", "(", "AgentData", ".", "class", ",", "new", "AgentData", "(", ")", ")", ";", "Bureau", "bureau", "=", "_bureaus", ".", "get", "(", "agent", ".", "bureauId", ...
Starts a new agent using the data in the given object, creating a new bureau if necessary.
[ "Starts", "a", "new", "agent", "using", "the", "data", "in", "the", "given", "object", "creating", "a", "new", "bureau", "if", "necessary", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L244-L280
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.destroyAgent
public void destroyAgent (AgentObject agent) { FoundAgent found = resolve(null, agent.getOid(), "destroyAgent"); if (found == null) { return; } log.info("Destroying agent", "agent", agent.which()); // transition the agent to a new state and perform the effect of the transition if (found.state == AgentState.PENDING) { found.bureau.agentStates.remove(found.agent); _omgr.destroyObject(found.agent.getOid()); } else if (found.state == AgentState.STARTED) { found.bureau.agentStates.put(found.agent, AgentState.STILL_BORN); } else if (found.state == AgentState.RUNNING) { // TODO: have a timeout for this in case the client is misbehaving or hung BureauSender.destroyAgent(found.bureau.clientObj, agent.getOid()); found.bureau.agentStates.put(found.agent, AgentState.DESTROYED); } else if (found.state == AgentState.DESTROYED || found.state == AgentState.STILL_BORN) { log.warning("Ignoring request to destroy agent in unexpected state", "state", found.state, "agent", found.agent.which()); } found.bureau.summarize(); }
java
public void destroyAgent (AgentObject agent) { FoundAgent found = resolve(null, agent.getOid(), "destroyAgent"); if (found == null) { return; } log.info("Destroying agent", "agent", agent.which()); // transition the agent to a new state and perform the effect of the transition if (found.state == AgentState.PENDING) { found.bureau.agentStates.remove(found.agent); _omgr.destroyObject(found.agent.getOid()); } else if (found.state == AgentState.STARTED) { found.bureau.agentStates.put(found.agent, AgentState.STILL_BORN); } else if (found.state == AgentState.RUNNING) { // TODO: have a timeout for this in case the client is misbehaving or hung BureauSender.destroyAgent(found.bureau.clientObj, agent.getOid()); found.bureau.agentStates.put(found.agent, AgentState.DESTROYED); } else if (found.state == AgentState.DESTROYED || found.state == AgentState.STILL_BORN) { log.warning("Ignoring request to destroy agent in unexpected state", "state", found.state, "agent", found.agent.which()); } found.bureau.summarize(); }
[ "public", "void", "destroyAgent", "(", "AgentObject", "agent", ")", "{", "FoundAgent", "found", "=", "resolve", "(", "null", ",", "agent", ".", "getOid", "(", ")", ",", "\"destroyAgent\"", ")", ";", "if", "(", "found", "==", "null", ")", "{", "return", ...
Destroys a previously started agent using the data in the given object.
[ "Destroys", "a", "previously", "started", "agent", "using", "the", "data", "in", "the", "given", "object", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L285-L314
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.lookupClient
public PresentsSession lookupClient (String bureauId) { Bureau bureau = _bureaus.get(bureauId); if (bureau == null) { return null; } return bureau.client; }
java
public PresentsSession lookupClient (String bureauId) { Bureau bureau = _bureaus.get(bureauId); if (bureau == null) { return null; } return bureau.client; }
[ "public", "PresentsSession", "lookupClient", "(", "String", "bureauId", ")", "{", "Bureau", "bureau", "=", "_bureaus", ".", "get", "(", "bureauId", ")", ";", "if", "(", "bureau", "==", "null", ")", "{", "return", "null", ";", "}", "return", "bureau", "."...
Returns the active session for a bureau of the given id.
[ "Returns", "the", "active", "session", "for", "a", "bureau", "of", "the", "given", "id", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L319-L326
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.getLaunchError
public Exception getLaunchError (AgentObject agentObj) { AgentData data = agentObj.getLocal(AgentData.class); if (data == null) { return null; } return data.launchError; }
java
public Exception getLaunchError (AgentObject agentObj) { AgentData data = agentObj.getLocal(AgentData.class); if (data == null) { return null; } return data.launchError; }
[ "public", "Exception", "getLaunchError", "(", "AgentObject", "agentObj", ")", "{", "AgentData", "data", "=", "agentObj", ".", "getLocal", "(", "AgentData", ".", "class", ")", ";", "if", "(", "data", "==", "null", ")", "{", "return", "null", ";", "}", "re...
If this agent's bureau encountered an error on launch, return it.
[ "If", "this", "agent", "s", "bureau", "encountered", "an", "error", "on", "launch", "return", "it", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L331-L338
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.bureauInitialized
protected void bureauInitialized (ClientObject client, String bureauId) { final Bureau bureau = _bureaus.get(bureauId); if (bureau == null) { log.warning("Initialization of non-existent bureau", "bureauId", bureauId); return; } bureau.clientObj = client; log.info("Bureau created, launching pending agents", "bureau", bureau); // find all pending agents Set<AgentObject> pending = Sets.newHashSet(); for (Map.Entry<AgentObject, AgentState> entry : bureau.agentStates.entrySet()) { if (entry.getValue() == AgentState.PENDING) { pending.add(entry.getKey()); } } // create them for (AgentObject agent : pending) { log.info("Creating agent", "agent", agent.which()); BureauSender.createAgent(bureau.clientObj, agent.getOid()); bureau.agentStates.put(agent, AgentState.STARTED); } bureau.summarize(); }
java
protected void bureauInitialized (ClientObject client, String bureauId) { final Bureau bureau = _bureaus.get(bureauId); if (bureau == null) { log.warning("Initialization of non-existent bureau", "bureauId", bureauId); return; } bureau.clientObj = client; log.info("Bureau created, launching pending agents", "bureau", bureau); // find all pending agents Set<AgentObject> pending = Sets.newHashSet(); for (Map.Entry<AgentObject, AgentState> entry : bureau.agentStates.entrySet()) { if (entry.getValue() == AgentState.PENDING) { pending.add(entry.getKey()); } } // create them for (AgentObject agent : pending) { log.info("Creating agent", "agent", agent.which()); BureauSender.createAgent(bureau.clientObj, agent.getOid()); bureau.agentStates.put(agent, AgentState.STARTED); } bureau.summarize(); }
[ "protected", "void", "bureauInitialized", "(", "ClientObject", "client", ",", "String", "bureauId", ")", "{", "final", "Bureau", "bureau", "=", "_bureaus", ".", "get", "(", "bureauId", ")", ";", "if", "(", "bureau", "==", "null", ")", "{", "log", ".", "w...
Callback for when the bureau client acknowledges starting up. Starts all pending agents and causes subsequent agent start requests to be sent directly to the bureau.
[ "Callback", "for", "when", "the", "bureau", "client", "acknowledges", "starting", "up", ".", "Starts", "all", "pending", "agents", "and", "causes", "subsequent", "agent", "start", "requests", "to", "be", "sent", "directly", "to", "the", "bureau", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L374-L405
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.agentCreated
protected void agentCreated (ClientObject client, int agentId) { FoundAgent found = resolve(client, agentId, "agentCreated"); if (found == null) { return; } log.info("Agent creation confirmed", "agent", found.agent.which()); if (found.state == AgentState.STARTED) { found.bureau.agentStates.put(found.agent, AgentState.RUNNING); found.agent.setClientOid(client.getOid()); } else if (found.state == AgentState.STILL_BORN) { // TODO: have a timeout for this in case the client is misbehaving or hung BureauSender.destroyAgent(found.bureau.clientObj, agentId); found.bureau.agentStates.put(found.agent, AgentState.DESTROYED); } else if (found.state == AgentState.PENDING || found.state == AgentState.RUNNING || found.state == AgentState.DESTROYED) { log.warning("Ignoring confirmation of creation of an agent in an unexpected state", "state", found.state, "agent", found.agent.which()); } found.bureau.summarize(); }
java
protected void agentCreated (ClientObject client, int agentId) { FoundAgent found = resolve(client, agentId, "agentCreated"); if (found == null) { return; } log.info("Agent creation confirmed", "agent", found.agent.which()); if (found.state == AgentState.STARTED) { found.bureau.agentStates.put(found.agent, AgentState.RUNNING); found.agent.setClientOid(client.getOid()); } else if (found.state == AgentState.STILL_BORN) { // TODO: have a timeout for this in case the client is misbehaving or hung BureauSender.destroyAgent(found.bureau.clientObj, agentId); found.bureau.agentStates.put(found.agent, AgentState.DESTROYED); } else if (found.state == AgentState.PENDING || found.state == AgentState.RUNNING || found.state == AgentState.DESTROYED) { log.warning("Ignoring confirmation of creation of an agent in an unexpected state", "state", found.state, "agent", found.agent.which()); } found.bureau.summarize(); }
[ "protected", "void", "agentCreated", "(", "ClientObject", "client", ",", "int", "agentId", ")", "{", "FoundAgent", "found", "=", "resolve", "(", "client", ",", "agentId", ",", "\"agentCreated\"", ")", ";", "if", "(", "found", "==", "null", ")", "{", "retur...
Callback for when the bureau client acknowledges the creation of an agent.
[ "Callback", "for", "when", "the", "bureau", "client", "acknowledges", "the", "creation", "of", "an", "agent", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L426-L452
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.agentCreationFailed
protected void agentCreationFailed (ClientObject client, int agentId) { FoundAgent found = resolve(client, agentId, "agentCreationFailed"); if (found == null) { return; } log.info("Agent creation failed", "agent", found.agent.which()); if (found.state == AgentState.STARTED || found.state == AgentState.STILL_BORN) { found.bureau.agentStates.remove(found.agent); _omgr.destroyObject(found.agent.getOid()); } else if (found.state == AgentState.PENDING || found.state == AgentState.RUNNING || found.state == AgentState.DESTROYED) { log.warning("Ignoring failure of creation of an agent in an unexpected state", "state", found.state, "agent", found.agent.which()); } found.bureau.summarize(); }
java
protected void agentCreationFailed (ClientObject client, int agentId) { FoundAgent found = resolve(client, agentId, "agentCreationFailed"); if (found == null) { return; } log.info("Agent creation failed", "agent", found.agent.which()); if (found.state == AgentState.STARTED || found.state == AgentState.STILL_BORN) { found.bureau.agentStates.remove(found.agent); _omgr.destroyObject(found.agent.getOid()); } else if (found.state == AgentState.PENDING || found.state == AgentState.RUNNING || found.state == AgentState.DESTROYED) { log.warning("Ignoring failure of creation of an agent in an unexpected state", "state", found.state, "agent", found.agent.which()); } found.bureau.summarize(); }
[ "protected", "void", "agentCreationFailed", "(", "ClientObject", "client", ",", "int", "agentId", ")", "{", "FoundAgent", "found", "=", "resolve", "(", "client", ",", "agentId", ",", "\"agentCreationFailed\"", ")", ";", "if", "(", "found", "==", "null", ")", ...
Callback for when the bureau client acknowledges the failure to create an agent.
[ "Callback", "for", "when", "the", "bureau", "client", "acknowledges", "the", "failure", "to", "create", "an", "agent", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L457-L479
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.clientDestroyed
protected void clientDestroyed (Bureau bureau) { log.info("Client destroyed, destroying all agents", "bureau", bureau); // clean up any agents attached to this bureau for (AgentObject agent : bureau.agentStates.keySet()) { _omgr.destroyObject(agent.getOid()); } bureau.agentStates.clear(); if (_bureaus.remove(bureau.bureauId) == null) { log.info("Bureau not found to remove", "bureau", bureau); } }
java
protected void clientDestroyed (Bureau bureau) { log.info("Client destroyed, destroying all agents", "bureau", bureau); // clean up any agents attached to this bureau for (AgentObject agent : bureau.agentStates.keySet()) { _omgr.destroyObject(agent.getOid()); } bureau.agentStates.clear(); if (_bureaus.remove(bureau.bureauId) == null) { log.info("Bureau not found to remove", "bureau", bureau); } }
[ "protected", "void", "clientDestroyed", "(", "Bureau", "bureau", ")", "{", "log", ".", "info", "(", "\"Client destroyed, destroying all agents\"", ",", "\"bureau\"", ",", "bureau", ")", ";", "// clean up any agents attached to this bureau", "for", "(", "AgentObject", "a...
Callback for when a client is destroyed.
[ "Callback", "for", "when", "a", "client", "is", "destroyed", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L511-L524
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.resolve
protected FoundAgent resolve (ClientObject client, int agentId, String resolver) { com.threerings.presents.dobj.DObject dobj = _omgr.getObject(agentId); if (dobj == null) { log.warning("Non-existent agent", "function", resolver, "agentId", agentId); return null; } if (!(dobj instanceof AgentObject)) { log.warning("Object not an agent", "function", resolver, "obj", dobj.getClass()); return null; } AgentObject agent = (AgentObject)dobj; Bureau bureau = _bureaus.get(agent.bureauId); if (bureau == null) { log.warning("Bureau not found for agent", "function", resolver, "agent", agent.which()); return null; } if (!bureau.agentStates.containsKey(agent)) { log.warning("Bureau does not have agent", "function", resolver, "agent", agent.which()); return null; } if (client != null && bureau.clientObj != client) { log.warning("Masquerading request", "function", resolver, "agent", agent.which(), "client", bureau.clientObj, "client", client); return null; } return new FoundAgent(bureau, agent, bureau.agentStates.get(agent)); }
java
protected FoundAgent resolve (ClientObject client, int agentId, String resolver) { com.threerings.presents.dobj.DObject dobj = _omgr.getObject(agentId); if (dobj == null) { log.warning("Non-existent agent", "function", resolver, "agentId", agentId); return null; } if (!(dobj instanceof AgentObject)) { log.warning("Object not an agent", "function", resolver, "obj", dobj.getClass()); return null; } AgentObject agent = (AgentObject)dobj; Bureau bureau = _bureaus.get(agent.bureauId); if (bureau == null) { log.warning("Bureau not found for agent", "function", resolver, "agent", agent.which()); return null; } if (!bureau.agentStates.containsKey(agent)) { log.warning("Bureau does not have agent", "function", resolver, "agent", agent.which()); return null; } if (client != null && bureau.clientObj != client) { log.warning("Masquerading request", "function", resolver, "agent", agent.which(), "client", bureau.clientObj, "client", client); return null; } return new FoundAgent(bureau, agent, bureau.agentStates.get(agent)); }
[ "protected", "FoundAgent", "resolve", "(", "ClientObject", "client", ",", "int", "agentId", ",", "String", "resolver", ")", "{", "com", ".", "threerings", ".", "presents", ".", "dobj", ".", "DObject", "dobj", "=", "_omgr", ".", "getObject", "(", "agentId", ...
Does lots of null checks and lookups and resolves the given information into FoundAgent.
[ "Does", "lots", "of", "null", "checks", "and", "lookups", "and", "resolves", "the", "given", "information", "into", "FoundAgent", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L529-L561
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.generateToken
protected String generateToken (String bureauId) { String tokenSource = bureauId + "@" + System.currentTimeMillis() + "r" + Math.random(); return StringUtil.md5hex(tokenSource); }
java
protected String generateToken (String bureauId) { String tokenSource = bureauId + "@" + System.currentTimeMillis() + "r" + Math.random(); return StringUtil.md5hex(tokenSource); }
[ "protected", "String", "generateToken", "(", "String", "bureauId", ")", "{", "String", "tokenSource", "=", "bureauId", "+", "\"@\"", "+", "System", ".", "currentTimeMillis", "(", ")", "+", "\"r\"", "+", "Math", ".", "random", "(", ")", ";", "return", "Stri...
Create a hard-to-guess token that the bureau can use to authenticate itself when it tries to log in.
[ "Create", "a", "hard", "-", "to", "-", "guess", "token", "that", "the", "bureau", "can", "use", "to", "authenticate", "itself", "when", "it", "tries", "to", "log", "in", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L567-L571
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.launchTimeoutExpired
protected void launchTimeoutExpired (Bureau bureau) { if (bureau.clientObj != null) { return; // all's well, ignore } if (!_bureaus.containsKey(bureau.bureauId)) { // bureau has already managed to get destroyed before the launch timeout, ignore return; } handleLaunchError(bureau, null, "timeout"); }
java
protected void launchTimeoutExpired (Bureau bureau) { if (bureau.clientObj != null) { return; // all's well, ignore } if (!_bureaus.containsKey(bureau.bureauId)) { // bureau has already managed to get destroyed before the launch timeout, ignore return; } handleLaunchError(bureau, null, "timeout"); }
[ "protected", "void", "launchTimeoutExpired", "(", "Bureau", "bureau", ")", "{", "if", "(", "bureau", ".", "clientObj", "!=", "null", ")", "{", "return", ";", "// all's well, ignore", "}", "if", "(", "!", "_bureaus", ".", "containsKey", "(", "bureau", ".", ...
Called by the launcher unit timeout time after launching. @param bureau bureau whose launch occurred
[ "Called", "by", "the", "launcher", "unit", "timeout", "time", "after", "launching", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L577-L589
train
threerings/narya
core/src/main/java/com/threerings/bureau/server/BureauRegistry.java
BureauRegistry.handleLaunchError
protected void handleLaunchError (Bureau bureau, Exception error, String cause) { if (cause == null && error != null) { cause = error.getMessage(); } log.info("Bureau failed to launch", "bureau", bureau, "cause", cause); // clean up any agents attached to this bureau for (AgentObject agent : bureau.agentStates.keySet()) { agent.getLocal(AgentData.class).launchError = error; _omgr.destroyObject(agent.getOid()); } bureau.agentStates.clear(); _bureaus.remove(bureau.bureauId); }
java
protected void handleLaunchError (Bureau bureau, Exception error, String cause) { if (cause == null && error != null) { cause = error.getMessage(); } log.info("Bureau failed to launch", "bureau", bureau, "cause", cause); // clean up any agents attached to this bureau for (AgentObject agent : bureau.agentStates.keySet()) { agent.getLocal(AgentData.class).launchError = error; _omgr.destroyObject(agent.getOid()); } bureau.agentStates.clear(); _bureaus.remove(bureau.bureauId); }
[ "protected", "void", "handleLaunchError", "(", "Bureau", "bureau", ",", "Exception", "error", ",", "String", "cause", ")", "{", "if", "(", "cause", "==", "null", "&&", "error", "!=", "null", ")", "{", "cause", "=", "error", ".", "getMessage", "(", ")", ...
Called when something goes wrong with launching a bureau.
[ "Called", "when", "something", "goes", "wrong", "with", "launching", "a", "bureau", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/bureau/server/BureauRegistry.java#L594-L609
train
threerings/narya
core/src/main/java/com/threerings/admin/client/ConfigEditorPanel.java
ConfigEditorPanel.gotConfigInfo
public void gotConfigInfo (final String[] keys, final int[] oids) { // make sure we're still added if (!isDisplayable()) { return; } Integer indexes[] = new Integer[keys.length]; for (int ii = 0; ii < indexes.length; ii++) { indexes[ii] = ii; } QuickSort.sort(indexes, new Comparator<Integer>() { public int compare (Integer i1, Integer i2) { return keys[i1].compareTo(keys[i2]); } }); // create object editor panels for each of the categories for (Integer ii : indexes) { ObjectEditorPanel panel = new ObjectEditorPanel(_ctx, keys[ii], oids[ii]); JScrollPane scrolly = new JScrollPane(panel); _oeditors.addTab(keys[ii], scrolly); if (keys[ii].equals(_defaultPane)) { _oeditors.setSelectedComponent(scrolly); } } }
java
public void gotConfigInfo (final String[] keys, final int[] oids) { // make sure we're still added if (!isDisplayable()) { return; } Integer indexes[] = new Integer[keys.length]; for (int ii = 0; ii < indexes.length; ii++) { indexes[ii] = ii; } QuickSort.sort(indexes, new Comparator<Integer>() { public int compare (Integer i1, Integer i2) { return keys[i1].compareTo(keys[i2]); } }); // create object editor panels for each of the categories for (Integer ii : indexes) { ObjectEditorPanel panel = new ObjectEditorPanel(_ctx, keys[ii], oids[ii]); JScrollPane scrolly = new JScrollPane(panel); _oeditors.addTab(keys[ii], scrolly); if (keys[ii].equals(_defaultPane)) { _oeditors.setSelectedComponent(scrolly); } } }
[ "public", "void", "gotConfigInfo", "(", "final", "String", "[", "]", "keys", ",", "final", "int", "[", "]", "oids", ")", "{", "// make sure we're still added", "if", "(", "!", "isDisplayable", "(", ")", ")", "{", "return", ";", "}", "Integer", "indexes", ...
Called in response to our getConfigInfo server-side service request.
[ "Called", "in", "response", "to", "our", "getConfigInfo", "server", "-", "side", "service", "request", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/client/ConfigEditorPanel.java#L112-L139
train
xbib/marc
src/main/java/org/xbib/marc/io/PatternInputStream.java
PatternInputStream.readChunk
@Override public Chunk<byte[], BytesReference> readChunk() throws IOException { Chunk<byte[], BytesReference> chunk = internalReadChunk(); if (chunk != null) { processChunk(chunk); } return chunk; }
java
@Override public Chunk<byte[], BytesReference> readChunk() throws IOException { Chunk<byte[], BytesReference> chunk = internalReadChunk(); if (chunk != null) { processChunk(chunk); } return chunk; }
[ "@", "Override", "public", "Chunk", "<", "byte", "[", "]", ",", "BytesReference", ">", "readChunk", "(", ")", "throws", "IOException", "{", "Chunk", "<", "byte", "[", "]", ",", "BytesReference", ">", "chunk", "=", "internalReadChunk", "(", ")", ";", "if"...
Read next chunk from this stream. @return a chunk @throws IOException if chunk can not be read
[ "Read", "next", "chunk", "from", "this", "stream", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/io/PatternInputStream.java#L72-L79
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.addChatterObserver
public boolean addChatterObserver (ChatterObserver co) { boolean added = _chatterObservers.add(co); co.chattersUpdated(_chatters.listIterator()); return added; }
java
public boolean addChatterObserver (ChatterObserver co) { boolean added = _chatterObservers.add(co); co.chattersUpdated(_chatters.listIterator()); return added; }
[ "public", "boolean", "addChatterObserver", "(", "ChatterObserver", "co", ")", "{", "boolean", "added", "=", "_chatterObservers", ".", "add", "(", "co", ")", ";", "co", ".", "chattersUpdated", "(", "_chatters", ".", "listIterator", "(", ")", ")", ";", "return...
Adds an observer that watches the chatters list, and updates it immediately.
[ "Adds", "an", "observer", "that", "watches", "the", "chatters", "list", "and", "updates", "it", "immediately", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L219-L225
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.registerCommandHandler
public void registerCommandHandler (MessageBundle msg, String command, CommandHandler handler) { // the usage key is derived from the untranslated command handler._usageKey = "m.usage_" + command; String key = "c." + command; handler._aliases = msg.exists(key) ? msg.get(key).split("\\s+") : new String[] { command }; for (String alias : handler._aliases) { _handlers.put(alias, handler); } }
java
public void registerCommandHandler (MessageBundle msg, String command, CommandHandler handler) { // the usage key is derived from the untranslated command handler._usageKey = "m.usage_" + command; String key = "c." + command; handler._aliases = msg.exists(key) ? msg.get(key).split("\\s+") : new String[] { command }; for (String alias : handler._aliases) { _handlers.put(alias, handler); } }
[ "public", "void", "registerCommandHandler", "(", "MessageBundle", "msg", ",", "String", "command", ",", "CommandHandler", "handler", ")", "{", "// the usage key is derived from the untranslated command", "handler", ".", "_usageKey", "=", "\"m.usage_\"", "+", "command", ";...
Registers a chat command handler. @param msg the message bundle via which the slash command will be translated (as <code>c.</code><i>command</i>). If no translation exists the command will be <code>/</code><i>command</i>. @param command the name of the command that will be used to invoke this handler (e.g. <code>tell</code> if the command will be invoked as <code>/tell</code>). @param handler the chat command handler itself.
[ "Registers", "a", "chat", "command", "handler", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L265-L275
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.clearDisplays
public void clearDisplays () { _displays.apply(new ObserverList.ObserverOp<ChatDisplay>() { public boolean apply (ChatDisplay observer) { observer.clear(); return true; } }); }
java
public void clearDisplays () { _displays.apply(new ObserverList.ObserverOp<ChatDisplay>() { public boolean apply (ChatDisplay observer) { observer.clear(); return true; } }); }
[ "public", "void", "clearDisplays", "(", ")", "{", "_displays", ".", "apply", "(", "new", "ObserverList", ".", "ObserverOp", "<", "ChatDisplay", ">", "(", ")", "{", "public", "boolean", "apply", "(", "ChatDisplay", "observer", ")", "{", "observer", ".", "cl...
Requests that all chat displays clear their contents.
[ "Requests", "that", "all", "chat", "displays", "clear", "their", "contents", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L304-L312
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.displayInfo
public void displayInfo (String bundle, String message) { displaySystem(bundle, message, SystemMessage.INFO, PLACE_CHAT_TYPE); }
java
public void displayInfo (String bundle, String message) { displaySystem(bundle, message, SystemMessage.INFO, PLACE_CHAT_TYPE); }
[ "public", "void", "displayInfo", "(", "String", "bundle", ",", "String", "message", ")", "{", "displaySystem", "(", "bundle", ",", "message", ",", "SystemMessage", ".", "INFO", ",", "PLACE_CHAT_TYPE", ")", ";", "}" ]
Display a system INFO message as if it had come from the server. The localtype of the message will be PLACE_CHAT_TYPE. Info messages are sent when something happens that was neither directly triggered by the user, nor requires direct action.
[ "Display", "a", "system", "INFO", "message", "as", "if", "it", "had", "come", "from", "the", "server", ".", "The", "localtype", "of", "the", "message", "will", "be", "PLACE_CHAT_TYPE", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L321-L324
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.displayInfo
public void displayInfo (String bundle, String message, String localtype) { displaySystem(bundle, message, SystemMessage.INFO, localtype); }
java
public void displayInfo (String bundle, String message, String localtype) { displaySystem(bundle, message, SystemMessage.INFO, localtype); }
[ "public", "void", "displayInfo", "(", "String", "bundle", ",", "String", "message", ",", "String", "localtype", ")", "{", "displaySystem", "(", "bundle", ",", "message", ",", "SystemMessage", ".", "INFO", ",", "localtype", ")", ";", "}" ]
Display a system INFO message as if it had come from the server. Info messages are sent when something happens that was neither directly triggered by the user, nor requires direct action.
[ "Display", "a", "system", "INFO", "message", "as", "if", "it", "had", "come", "from", "the", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L332-L335
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.displayFeedback
public void displayFeedback (String bundle, String message) { displaySystem(bundle, message, SystemMessage.FEEDBACK, PLACE_CHAT_TYPE); }
java
public void displayFeedback (String bundle, String message) { displaySystem(bundle, message, SystemMessage.FEEDBACK, PLACE_CHAT_TYPE); }
[ "public", "void", "displayFeedback", "(", "String", "bundle", ",", "String", "message", ")", "{", "displaySystem", "(", "bundle", ",", "message", ",", "SystemMessage", ".", "FEEDBACK", ",", "PLACE_CHAT_TYPE", ")", ";", "}" ]
Display a system FEEDBACK message as if it had come from the server. The localtype of the message will be PLACE_CHAT_TYPE. Feedback messages are sent in direct response to a user action, usually to indicate success or failure of the user's action.
[ "Display", "a", "system", "FEEDBACK", "message", "as", "if", "it", "had", "come", "from", "the", "server", ".", "The", "localtype", "of", "the", "message", "will", "be", "PLACE_CHAT_TYPE", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L344-L347
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.displayAttention
public void displayAttention (String bundle, String message) { displaySystem(bundle, message, SystemMessage.ATTENTION, PLACE_CHAT_TYPE); }
java
public void displayAttention (String bundle, String message) { displaySystem(bundle, message, SystemMessage.ATTENTION, PLACE_CHAT_TYPE); }
[ "public", "void", "displayAttention", "(", "String", "bundle", ",", "String", "message", ")", "{", "displaySystem", "(", "bundle", ",", "message", ",", "SystemMessage", ".", "ATTENTION", ",", "PLACE_CHAT_TYPE", ")", ";", "}" ]
Display a system ATTENTION message as if it had come from the server. The localtype of the message will be PLACE_CHAT_TYPE. Attention messages are sent when something requires user action that did not result from direct action by the user.
[ "Display", "a", "system", "ATTENTION", "message", "as", "if", "it", "had", "come", "from", "the", "server", ".", "The", "localtype", "of", "the", "message", "will", "be", "PLACE_CHAT_TYPE", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L356-L359
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.dispatchMessage
public void dispatchMessage (ChatMessage message, String localType) { setClientInfo(message, localType); dispatchPreparedMessage(message); }
java
public void dispatchMessage (ChatMessage message, String localType) { setClientInfo(message, localType); dispatchPreparedMessage(message); }
[ "public", "void", "dispatchMessage", "(", "ChatMessage", "message", ",", "String", "localType", ")", "{", "setClientInfo", "(", "message", ",", "localType", ")", ";", "dispatchPreparedMessage", "(", "message", ")", ";", "}" ]
Dispatches the provided message to our chat displays.
[ "Dispatches", "the", "provided", "message", "to", "our", "chat", "displays", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L364-L368
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.requestChat
public String requestChat (SpeakService speakSvc, String text, boolean record) { if (text.startsWith("/")) { // split the text up into a command and arguments String command = text.substring(1).toLowerCase(); String[] hist = new String[1]; String args = ""; int sidx = text.indexOf(" "); if (sidx != -1) { command = text.substring(1, sidx).toLowerCase(); args = text.substring(sidx + 1).trim(); } Map<String, CommandHandler> possibleCommands = getCommandHandlers(command); switch (possibleCommands.size()) { case 0: StringTokenizer tok = new StringTokenizer(text); return MessageBundle.tcompose("m.unknown_command", tok.nextToken()); case 1: Map.Entry<String, CommandHandler> entry = possibleCommands.entrySet().iterator().next(); String cmdName = entry.getKey(); CommandHandler cmd = entry.getValue(); String result = cmd.handleCommand(speakSvc, cmdName, args, hist); if (!result.equals(ChatCodes.SUCCESS)) { return result; } if (record) { // get the final history-ready command string hist[0] = "/" + ((hist[0] == null) ? command : hist[0]); // remove from history if it was present and add it to the end addToHistory(hist[0]); } return result; default: StringBuilder buf = new StringBuilder(); for (String pcmd : Sets.newTreeSet(possibleCommands.keySet())) { buf.append(" /").append(pcmd); } return MessageBundle.tcompose("m.unspecific_command", buf.toString()); } } // if not a command then just speak String message = text.trim(); if (StringUtil.isBlank(message)) { // report silent failure for now return ChatCodes.SUCCESS; } return deliverChat(speakSvc, message, ChatCodes.DEFAULT_MODE); }
java
public String requestChat (SpeakService speakSvc, String text, boolean record) { if (text.startsWith("/")) { // split the text up into a command and arguments String command = text.substring(1).toLowerCase(); String[] hist = new String[1]; String args = ""; int sidx = text.indexOf(" "); if (sidx != -1) { command = text.substring(1, sidx).toLowerCase(); args = text.substring(sidx + 1).trim(); } Map<String, CommandHandler> possibleCommands = getCommandHandlers(command); switch (possibleCommands.size()) { case 0: StringTokenizer tok = new StringTokenizer(text); return MessageBundle.tcompose("m.unknown_command", tok.nextToken()); case 1: Map.Entry<String, CommandHandler> entry = possibleCommands.entrySet().iterator().next(); String cmdName = entry.getKey(); CommandHandler cmd = entry.getValue(); String result = cmd.handleCommand(speakSvc, cmdName, args, hist); if (!result.equals(ChatCodes.SUCCESS)) { return result; } if (record) { // get the final history-ready command string hist[0] = "/" + ((hist[0] == null) ? command : hist[0]); // remove from history if it was present and add it to the end addToHistory(hist[0]); } return result; default: StringBuilder buf = new StringBuilder(); for (String pcmd : Sets.newTreeSet(possibleCommands.keySet())) { buf.append(" /").append(pcmd); } return MessageBundle.tcompose("m.unspecific_command", buf.toString()); } } // if not a command then just speak String message = text.trim(); if (StringUtil.isBlank(message)) { // report silent failure for now return ChatCodes.SUCCESS; } return deliverChat(speakSvc, message, ChatCodes.DEFAULT_MODE); }
[ "public", "String", "requestChat", "(", "SpeakService", "speakSvc", ",", "String", "text", ",", "boolean", "record", ")", "{", "if", "(", "text", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "// split the text up into a command and arguments", "String", "comman...
Parses and delivers the supplied chat message. Slash command processing and mogrification are performed and the message is added to the chat history if appropriate. @param speakSvc the SpeakService representing the target dobj of the speak or null if we should speak in the "default" way. @param text the text to be parsed and sent. @param record if text is a command, should it be added to the history? @return <code>ChatCodes#SUCCESS</code> if the message was parsed and sent correctly, a translatable error string if there was some problem.
[ "Parses", "and", "delivers", "the", "supplied", "chat", "message", ".", "Slash", "command", "processing", "and", "mogrification", "are", "performed", "and", "the", "message", "is", "added", "to", "the", "chat", "history", "if", "appropriate", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L382-L439
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.requestBroadcast
public void requestBroadcast (String message) { message = filter(message, null, true); if (message == null) { displayFeedback(_bundle, MessageBundle.compose("m.broadcast_failed", "m.filtered")); return; } _cservice.broadcast(message, new ChatService.InvocationListener() { public void requestFailed (String reason) { reason = MessageBundle.compose("m.broadcast_failed", reason); displayFeedback(_bundle, reason); } }); }
java
public void requestBroadcast (String message) { message = filter(message, null, true); if (message == null) { displayFeedback(_bundle, MessageBundle.compose("m.broadcast_failed", "m.filtered")); return; } _cservice.broadcast(message, new ChatService.InvocationListener() { public void requestFailed (String reason) { reason = MessageBundle.compose("m.broadcast_failed", reason); displayFeedback(_bundle, reason); } }); }
[ "public", "void", "requestBroadcast", "(", "String", "message", ")", "{", "message", "=", "filter", "(", "message", ",", "null", ",", "true", ")", ";", "if", "(", "message", "==", "null", ")", "{", "displayFeedback", "(", "_bundle", ",", "MessageBundle", ...
Requests to send a site-wide broadcast message. @param message the contents of the message.
[ "Requests", "to", "send", "a", "site", "-", "wide", "broadcast", "message", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L477-L490
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.requestTell
public <T extends Name> void requestTell ( final T target, String msg, final ResultListener<T> rl) { // make sure they can say what they want to say final String message = filter(msg, target, true); if (message == null) { if (rl != null) { rl.requestFailed(null); } return; } // create a listener that will report success or failure ChatService.TellListener listener = new ChatService.TellListener() { public void tellSucceeded (long idletime, String awayMessage) { success(); // if they have an away message, report that if (awayMessage != null) { awayMessage = filter(awayMessage, target, false); if (awayMessage != null) { String msg = MessageBundle.tcompose("m.recipient_afk", target, awayMessage); displayFeedback(_bundle, msg); } } // if they are idle, report that if (idletime > 0L) { // adjust by the time it took them to become idle idletime += _ctx.getConfig().getValue(IDLE_TIME_KEY, DEFAULT_IDLE_TIME); String msg = MessageBundle.compose( "m.recipient_idle", MessageBundle.taint(target), TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE)); displayFeedback(_bundle, msg); } } protected void success () { dispatchMessage(new TellFeedbackMessage(target, message, false), ChatCodes.PLACE_CHAT_TYPE); addChatter(target); if (rl != null) { rl.requestCompleted(target); } } public void requestFailed (String reason) { String msg = MessageBundle.compose( "m.tell_failed", MessageBundle.taint(target), reason); TellFeedbackMessage tfm = new TellFeedbackMessage(target, msg, true); tfm.bundle = _bundle; dispatchMessage(tfm, ChatCodes.PLACE_CHAT_TYPE); if (rl != null) { rl.requestFailed(null); } } }; _cservice.tell(target, message, listener); }
java
public <T extends Name> void requestTell ( final T target, String msg, final ResultListener<T> rl) { // make sure they can say what they want to say final String message = filter(msg, target, true); if (message == null) { if (rl != null) { rl.requestFailed(null); } return; } // create a listener that will report success or failure ChatService.TellListener listener = new ChatService.TellListener() { public void tellSucceeded (long idletime, String awayMessage) { success(); // if they have an away message, report that if (awayMessage != null) { awayMessage = filter(awayMessage, target, false); if (awayMessage != null) { String msg = MessageBundle.tcompose("m.recipient_afk", target, awayMessage); displayFeedback(_bundle, msg); } } // if they are idle, report that if (idletime > 0L) { // adjust by the time it took them to become idle idletime += _ctx.getConfig().getValue(IDLE_TIME_KEY, DEFAULT_IDLE_TIME); String msg = MessageBundle.compose( "m.recipient_idle", MessageBundle.taint(target), TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE)); displayFeedback(_bundle, msg); } } protected void success () { dispatchMessage(new TellFeedbackMessage(target, message, false), ChatCodes.PLACE_CHAT_TYPE); addChatter(target); if (rl != null) { rl.requestCompleted(target); } } public void requestFailed (String reason) { String msg = MessageBundle.compose( "m.tell_failed", MessageBundle.taint(target), reason); TellFeedbackMessage tfm = new TellFeedbackMessage(target, msg, true); tfm.bundle = _bundle; dispatchMessage(tfm, ChatCodes.PLACE_CHAT_TYPE); if (rl != null) { rl.requestFailed(null); } } }; _cservice.tell(target, message, listener); }
[ "public", "<", "T", "extends", "Name", ">", "void", "requestTell", "(", "final", "T", "target", ",", "String", "msg", ",", "final", "ResultListener", "<", "T", ">", "rl", ")", "{", "// make sure they can say what they want to say", "final", "String", "message", ...
Requests that a tell message be delivered to the specified target user. @param target the username of the user to which the tell message should be delivered. @param msg the contents of the tell message. @param rl an optional result listener if you'd like to be notified of success or failure.
[ "Requests", "that", "a", "tell", "message", "be", "delivered", "to", "the", "specified", "target", "user", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L499-L558
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.setAwayMessage
public void setAwayMessage (String message) { if (message != null) { message = filter(message, null, true); if (message == null) { // they filtered away their own away message... change it to something message = "..."; } } // pass the buck right on along _cservice.away(message); }
java
public void setAwayMessage (String message) { if (message != null) { message = filter(message, null, true); if (message == null) { // they filtered away their own away message... change it to something message = "..."; } } // pass the buck right on along _cservice.away(message); }
[ "public", "void", "setAwayMessage", "(", "String", "message", ")", "{", "if", "(", "message", "!=", "null", ")", "{", "message", "=", "filter", "(", "message", ",", "null", ",", "true", ")", ";", "if", "(", "message", "==", "null", ")", "{", "// they...
Configures a message that will be automatically reported to anyone that sends a tell message to this client to indicate that we are busy or away from the keyboard.
[ "Configures", "a", "message", "that", "will", "be", "automatically", "reported", "to", "anyone", "that", "sends", "a", "tell", "message", "to", "this", "client", "to", "indicate", "that", "we", "are", "busy", "or", "away", "from", "the", "keyboard", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L564-L575
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.addAuxiliarySource
public void addAuxiliarySource (DObject source, String localtype) { source.addListener(this); _auxes.put(source.getOid(), localtype); }
java
public void addAuxiliarySource (DObject source, String localtype) { source.addListener(this); _auxes.put(source.getOid(), localtype); }
[ "public", "void", "addAuxiliarySource", "(", "DObject", "source", ",", "String", "localtype", ")", "{", "source", ".", "addListener", "(", "this", ")", ";", "_auxes", ".", "put", "(", "source", ".", "getOid", "(", ")", ",", "localtype", ")", ";", "}" ]
Adds an additional object via which chat messages may arrive. The chat director assumes the caller will be managing the subscription to this object and will remain subscribed to it for as long as it remains in effect as an auxiliary chat source. @param localtype a type to be associated with all chat messages that arrive on the specified DObject.
[ "Adds", "an", "additional", "object", "via", "which", "chat", "messages", "may", "arrive", ".", "The", "chat", "director", "assumes", "the", "caller", "will", "be", "managing", "the", "subscription", "to", "this", "object", "and", "will", "remain", "subscribed...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L585-L589
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.filter
public String filter (String msg, Name otherUser, boolean outgoing) { _filterMessageOp.setMessage(msg, otherUser, outgoing); _filters.apply(_filterMessageOp); return _filterMessageOp.getMessage(); }
java
public String filter (String msg, Name otherUser, boolean outgoing) { _filterMessageOp.setMessage(msg, otherUser, outgoing); _filters.apply(_filterMessageOp); return _filterMessageOp.getMessage(); }
[ "public", "String", "filter", "(", "String", "msg", ",", "Name", "otherUser", ",", "boolean", "outgoing", ")", "{", "_filterMessageOp", ".", "setMessage", "(", "msg", ",", "otherUser", ",", "outgoing", ")", ";", "_filters", ".", "apply", "(", "_filterMessage...
Run a message through all the currently registered filters.
[ "Run", "a", "message", "through", "all", "the", "currently", "registered", "filters", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L618-L623
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.registerCommandHandlers
protected void registerCommandHandlers () { MessageBundle msg = _ctx.getMessageManager().getBundle(_bundle); registerCommandHandler(msg, "help", new HelpHandler()); registerCommandHandler(msg, "clear", new ClearHandler()); registerCommandHandler(msg, "speak", new SpeakHandler()); registerCommandHandler(msg, "emote", new EmoteHandler()); registerCommandHandler(msg, "think", new ThinkHandler()); registerCommandHandler(msg, "tell", new TellHandler()); registerCommandHandler(msg, "broadcast", new BroadcastHandler()); }
java
protected void registerCommandHandlers () { MessageBundle msg = _ctx.getMessageManager().getBundle(_bundle); registerCommandHandler(msg, "help", new HelpHandler()); registerCommandHandler(msg, "clear", new ClearHandler()); registerCommandHandler(msg, "speak", new SpeakHandler()); registerCommandHandler(msg, "emote", new EmoteHandler()); registerCommandHandler(msg, "think", new ThinkHandler()); registerCommandHandler(msg, "tell", new TellHandler()); registerCommandHandler(msg, "broadcast", new BroadcastHandler()); }
[ "protected", "void", "registerCommandHandlers", "(", ")", "{", "MessageBundle", "msg", "=", "_ctx", ".", "getMessageManager", "(", ")", ".", "getBundle", "(", "_bundle", ")", ";", "registerCommandHandler", "(", "msg", ",", "\"help\"", ",", "new", "HelpHandler", ...
Registers all the chat-command handlers.
[ "Registers", "all", "the", "chat", "-", "command", "handlers", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L721-L731
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.processReceivedMessage
protected void processReceivedMessage (ChatMessage msg, String localtype) { String autoResponse = null; Name speaker = null; Name speakerDisplay = null; byte mode = (byte)-1; // figure out if the message was triggered by another user if (msg instanceof UserMessage) { UserMessage umsg = (UserMessage)msg; speaker = umsg.speaker; speakerDisplay = umsg.getSpeakerDisplayName(); mode = umsg.mode; } else if (msg instanceof UserSystemMessage) { speaker = ((UserSystemMessage)msg).speaker; speakerDisplay = speaker; } // Translate and timestamp the message. This would happen during dispatch but we // need to do it ahead of filtering. setClientInfo(msg, localtype); // if there was an originating speaker, see if we want to hear it if (speaker != null) { if (shouldFilter(msg) && (msg.message = filter(msg.message, speaker, false)) == null) { return; } if (USER_CHAT_TYPE.equals(localtype) && mode == ChatCodes.DEFAULT_MODE) { // if it was a tell, add the speaker as a chatter addChatter(speaker); // note whether or not we have an auto-response BodyObject self = (BodyObject)_ctx.getClient().getClientObject(); if (!StringUtil.isBlank(self.awayMessage)) { autoResponse = self.awayMessage; } } } // and send it off! dispatchMessage(msg, localtype); // if we auto-responded, report as much if (autoResponse != null) { String amsg = MessageBundle.tcompose( "m.auto_responded", speakerDisplay, autoResponse); displayFeedback(_bundle, amsg); } }
java
protected void processReceivedMessage (ChatMessage msg, String localtype) { String autoResponse = null; Name speaker = null; Name speakerDisplay = null; byte mode = (byte)-1; // figure out if the message was triggered by another user if (msg instanceof UserMessage) { UserMessage umsg = (UserMessage)msg; speaker = umsg.speaker; speakerDisplay = umsg.getSpeakerDisplayName(); mode = umsg.mode; } else if (msg instanceof UserSystemMessage) { speaker = ((UserSystemMessage)msg).speaker; speakerDisplay = speaker; } // Translate and timestamp the message. This would happen during dispatch but we // need to do it ahead of filtering. setClientInfo(msg, localtype); // if there was an originating speaker, see if we want to hear it if (speaker != null) { if (shouldFilter(msg) && (msg.message = filter(msg.message, speaker, false)) == null) { return; } if (USER_CHAT_TYPE.equals(localtype) && mode == ChatCodes.DEFAULT_MODE) { // if it was a tell, add the speaker as a chatter addChatter(speaker); // note whether or not we have an auto-response BodyObject self = (BodyObject)_ctx.getClient().getClientObject(); if (!StringUtil.isBlank(self.awayMessage)) { autoResponse = self.awayMessage; } } } // and send it off! dispatchMessage(msg, localtype); // if we auto-responded, report as much if (autoResponse != null) { String amsg = MessageBundle.tcompose( "m.auto_responded", speakerDisplay, autoResponse); displayFeedback(_bundle, amsg); } }
[ "protected", "void", "processReceivedMessage", "(", "ChatMessage", "msg", ",", "String", "localtype", ")", "{", "String", "autoResponse", "=", "null", ";", "Name", "speaker", "=", "null", ";", "Name", "speakerDisplay", "=", "null", ";", "byte", "mode", "=", ...
Processes and dispatches the specified chat message.
[ "Processes", "and", "dispatches", "the", "specified", "chat", "message", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L736-L787
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.addToHistory
protected void addToHistory (String cmd) { // remove any previous instance of this command _history.remove(cmd); // append it to the end _history.add(cmd); // prune the history once it extends beyond max size if (_history.size() > MAX_COMMAND_HISTORY) { _history.remove(0); } }
java
protected void addToHistory (String cmd) { // remove any previous instance of this command _history.remove(cmd); // append it to the end _history.add(cmd); // prune the history once it extends beyond max size if (_history.size() > MAX_COMMAND_HISTORY) { _history.remove(0); } }
[ "protected", "void", "addToHistory", "(", "String", "cmd", ")", "{", "// remove any previous instance of this command", "_history", ".", "remove", "(", "cmd", ")", ";", "// append it to the end", "_history", ".", "add", "(", "cmd", ")", ";", "// prune the history once...
Adds the specified command to the history.
[ "Adds", "the", "specified", "command", "to", "the", "history", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L853-L865
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.mogrifyChat
protected String mogrifyChat ( String text, byte mode, boolean transformsAllowed, boolean capFirst) { int tlen = text.length(); if (tlen == 0) { return text; // check to make sure there aren't too many caps } else if (tlen > 7 && suppressTooManyCaps()) { // count caps int caps = 0; for (int ii=0; ii < tlen; ii++) { if (Character.isUpperCase(text.charAt(ii))) { caps++; if (caps > (tlen / 2)) { // lowercase the whole string if there are text = text.toLowerCase(); break; } } } } StringBuffer buf = new StringBuffer(text); buf = mogrifyChat(buf, transformsAllowed, capFirst); return buf.toString(); }
java
protected String mogrifyChat ( String text, byte mode, boolean transformsAllowed, boolean capFirst) { int tlen = text.length(); if (tlen == 0) { return text; // check to make sure there aren't too many caps } else if (tlen > 7 && suppressTooManyCaps()) { // count caps int caps = 0; for (int ii=0; ii < tlen; ii++) { if (Character.isUpperCase(text.charAt(ii))) { caps++; if (caps > (tlen / 2)) { // lowercase the whole string if there are text = text.toLowerCase(); break; } } } } StringBuffer buf = new StringBuffer(text); buf = mogrifyChat(buf, transformsAllowed, capFirst); return buf.toString(); }
[ "protected", "String", "mogrifyChat", "(", "String", "text", ",", "byte", "mode", ",", "boolean", "transformsAllowed", ",", "boolean", "capFirst", ")", "{", "int", "tlen", "=", "text", ".", "length", "(", ")", ";", "if", "(", "tlen", "==", "0", ")", "{...
Mogrifies common literary crutches into more appealing chat or commands. @param mode the chat mode, or -1 if unknown. @param transformsAllowed if true, the chat may transformed into a different mode. (lol -> /emote laughs) @param capFirst if true, the first letter of the text is capitalized. This is not desired if the chat is already an emote.
[ "Mogrifies", "common", "literary", "crutches", "into", "more", "appealing", "chat", "or", "commands", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L876-L902
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.addChatter
protected void addChatter (Name name) { // check to see if the chatter validator approves.. if ((_chatterValidator != null) && (!_chatterValidator.isChatterValid(name))) { return; } boolean wasthere = _chatters.remove(name); _chatters.addFirst(name); if (!wasthere) { if (_chatters.size() > MAX_CHATTERS) { _chatters.removeLast(); } notifyChatterObservers(); } }
java
protected void addChatter (Name name) { // check to see if the chatter validator approves.. if ((_chatterValidator != null) && (!_chatterValidator.isChatterValid(name))) { return; } boolean wasthere = _chatters.remove(name); _chatters.addFirst(name); if (!wasthere) { if (_chatters.size() > MAX_CHATTERS) { _chatters.removeLast(); } notifyChatterObservers(); } }
[ "protected", "void", "addChatter", "(", "Name", "name", ")", "{", "// check to see if the chatter validator approves..", "if", "(", "(", "_chatterValidator", "!=", "null", ")", "&&", "(", "!", "_chatterValidator", ".", "isChatterValid", "(", "name", ")", ")", ")",...
Adds a chatter to our list of recent chatters.
[ "Adds", "a", "chatter", "to", "our", "list", "of", "recent", "chatters", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L1025-L1040
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.setClientInfo
protected void setClientInfo (ChatMessage msg, String localType) { if (msg.localtype == null) { msg.setClientInfo(xlate(msg.bundle, msg.message), localType); } }
java
protected void setClientInfo (ChatMessage msg, String localType) { if (msg.localtype == null) { msg.setClientInfo(xlate(msg.bundle, msg.message), localType); } }
[ "protected", "void", "setClientInfo", "(", "ChatMessage", "msg", ",", "String", "localType", ")", "{", "if", "(", "msg", ".", "localtype", "==", "null", ")", "{", "msg", ".", "setClientInfo", "(", "xlate", "(", "msg", ".", "bundle", ",", "msg", ".", "m...
Set the "client info" on the specified message, if not already set.
[ "Set", "the", "client", "info", "on", "the", "specified", "message", "if", "not", "already", "set", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L1058-L1063
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.xlate
protected String xlate (String bundle, String message) { if (bundle != null && _ctx.getMessageManager() != null) { MessageBundle msgb = _ctx.getMessageManager().getBundle(bundle); if (msgb == null) { log.warning("No message bundle available to translate message", "bundle", bundle, "message", message); } else { message = msgb.xlate(message); } } return message; }
java
protected String xlate (String bundle, String message) { if (bundle != null && _ctx.getMessageManager() != null) { MessageBundle msgb = _ctx.getMessageManager().getBundle(bundle); if (msgb == null) { log.warning("No message bundle available to translate message", "bundle", bundle, "message", message); } else { message = msgb.xlate(message); } } return message; }
[ "protected", "String", "xlate", "(", "String", "bundle", ",", "String", "message", ")", "{", "if", "(", "bundle", "!=", "null", "&&", "_ctx", ".", "getMessageManager", "(", ")", "!=", "null", ")", "{", "MessageBundle", "msgb", "=", "_ctx", ".", "getMessa...
Translates the specified message using the specified bundle.
[ "Translates", "the", "specified", "message", "using", "the", "specified", "bundle", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L1068-L1080
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.displaySystem
protected void displaySystem (String bundle, String message, byte attLevel, String localtype) { // nothing should be untranslated, so pass the default bundle if need be. if (bundle == null) { bundle = _bundle; } SystemMessage msg = new SystemMessage(message, bundle, attLevel); dispatchMessage(msg, localtype); }
java
protected void displaySystem (String bundle, String message, byte attLevel, String localtype) { // nothing should be untranslated, so pass the default bundle if need be. if (bundle == null) { bundle = _bundle; } SystemMessage msg = new SystemMessage(message, bundle, attLevel); dispatchMessage(msg, localtype); }
[ "protected", "void", "displaySystem", "(", "String", "bundle", ",", "String", "message", ",", "byte", "attLevel", ",", "String", "localtype", ")", "{", "// nothing should be untranslated, so pass the default bundle if need be.", "if", "(", "bundle", "==", "null", ")", ...
Display the specified system message as if it had come from the server.
[ "Display", "the", "specified", "system", "message", "as", "if", "it", "had", "come", "from", "the", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L1085-L1093
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java
ChatDirector.getLocalType
protected String getLocalType (int oid) { String type = _auxes.get(oid); return (type == null) ? PLACE_CHAT_TYPE : type; }
java
protected String getLocalType (int oid) { String type = _auxes.get(oid); return (type == null) ? PLACE_CHAT_TYPE : type; }
[ "protected", "String", "getLocalType", "(", "int", "oid", ")", "{", "String", "type", "=", "_auxes", ".", "get", "(", "oid", ")", ";", "return", "(", "type", "==", "null", ")", "?", "PLACE_CHAT_TYPE", ":", "type", ";", "}" ]
Looks up and returns the message type associated with the specified oid.
[ "Looks", "up", "and", "returns", "the", "message", "type", "associated", "with", "the", "specified", "oid", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L1098-L1102
train
dkpro/dkpro-argumentation
dkpro-argumentation-io/src/main/java/org/dkpro/argumentation/io/writer/ArgumentDumpWriter.java
ArgumentDumpWriter.dumpArguments
public static String dumpArguments(JCas jCas, boolean includeProperties, boolean includeRelations) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outputStream); String documentId = DocumentMetaData.get(jCas).getDocumentId(); out.println("======== #" + documentId + " begin =========================="); Collection<ArgumentComponent> argumentComponents = JCasUtil .select(jCas, ArgumentComponent.class); out.println("----------------- ArgumentComponent -----------------"); out.println("# of argument units: " + argumentComponents.size()); for (ArgumentComponent argumentComponent : argumentComponents) { out.println(argumentUnitToString(argumentComponent)); if (includeProperties) { out.println(formatProperties(argumentComponent)); } if (argumentComponent instanceof Claim) { Claim claim = (Claim) argumentComponent; String stance = claim.getStance(); if (stance != null) { out.println("Stance: " + stance); } } } Collection<ArgumentRelation> argumentRelations = JCasUtil .select(jCas, ArgumentRelation.class); if (includeRelations) { out.println("----------------- ArgumentRelation -----------------"); out.println("# of argument relations: " + argumentRelations.size()); for (ArgumentRelation argumentRelation : argumentRelations) { out.println(argumentRelation.getType().getShortName()); out.println(" source: " + argumentUnitToString( argumentRelation.getSource())); out.println(" target: " + argumentUnitToString( argumentRelation.getTarget())); if (includeProperties) { out.println(formatProperties(argumentRelation)); } } } out.println("======== #" + documentId + " end =========================="); try { return outputStream.toString("utf-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
java
public static String dumpArguments(JCas jCas, boolean includeProperties, boolean includeRelations) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outputStream); String documentId = DocumentMetaData.get(jCas).getDocumentId(); out.println("======== #" + documentId + " begin =========================="); Collection<ArgumentComponent> argumentComponents = JCasUtil .select(jCas, ArgumentComponent.class); out.println("----------------- ArgumentComponent -----------------"); out.println("# of argument units: " + argumentComponents.size()); for (ArgumentComponent argumentComponent : argumentComponents) { out.println(argumentUnitToString(argumentComponent)); if (includeProperties) { out.println(formatProperties(argumentComponent)); } if (argumentComponent instanceof Claim) { Claim claim = (Claim) argumentComponent; String stance = claim.getStance(); if (stance != null) { out.println("Stance: " + stance); } } } Collection<ArgumentRelation> argumentRelations = JCasUtil .select(jCas, ArgumentRelation.class); if (includeRelations) { out.println("----------------- ArgumentRelation -----------------"); out.println("# of argument relations: " + argumentRelations.size()); for (ArgumentRelation argumentRelation : argumentRelations) { out.println(argumentRelation.getType().getShortName()); out.println(" source: " + argumentUnitToString( argumentRelation.getSource())); out.println(" target: " + argumentUnitToString( argumentRelation.getTarget())); if (includeProperties) { out.println(formatProperties(argumentRelation)); } } } out.println("======== #" + documentId + " end =========================="); try { return outputStream.toString("utf-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
[ "public", "static", "String", "dumpArguments", "(", "JCas", "jCas", ",", "boolean", "includeProperties", ",", "boolean", "includeRelations", ")", "{", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "PrintStream", "out", ...
Dump argument components to String. Can be also used outside UIMA pipeline. @param jCas jcas @return string dump
[ "Dump", "argument", "components", "to", "String", ".", "Can", "be", "also", "used", "outside", "UIMA", "pipeline", "." ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-io/src/main/java/org/dkpro/argumentation/io/writer/ArgumentDumpWriter.java#L119-L179
train
dkpro/dkpro-argumentation
dkpro-argumentation-io/src/main/java/org/dkpro/argumentation/io/writer/ArgumentDumpWriter.java
ArgumentDumpWriter.argumentUnitToString
public static String argumentUnitToString(ArgumentUnit argumentUnit) { return String.format("%s [%d, %d] \"%s\"", argumentUnit.getType().getShortName(), argumentUnit.getBegin(), argumentUnit.getEnd(), argumentUnit.getCoveredText()); }
java
public static String argumentUnitToString(ArgumentUnit argumentUnit) { return String.format("%s [%d, %d] \"%s\"", argumentUnit.getType().getShortName(), argumentUnit.getBegin(), argumentUnit.getEnd(), argumentUnit.getCoveredText()); }
[ "public", "static", "String", "argumentUnitToString", "(", "ArgumentUnit", "argumentUnit", ")", "{", "return", "String", ".", "format", "(", "\"%s [%d, %d] \\\"%s\\\"\"", ",", "argumentUnit", ".", "getType", "(", ")", ".", "getShortName", "(", ")", ",", "argumentU...
Formats argument unit to string with type, position, and text content @param argumentUnit argument unit @return string
[ "Formats", "argument", "unit", "to", "string", "with", "type", "position", "and", "text", "content" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-io/src/main/java/org/dkpro/argumentation/io/writer/ArgumentDumpWriter.java#L194-L198
train
threerings/narya
core/src/main/java/com/threerings/admin/server/persist/ConfigRepository.java
ConfigRepository.loadConfig
public HashMap<String, String> loadConfig (String node, String object) { HashMap<String, String> data = Maps.newHashMap(); for (ConfigRecord record : from(ConfigRecord.class). where(ConfigRecord.OBJECT.eq(object), ConfigRecord.NODE.eq(node)).select()) { data.put(record.field, record.value); } return data; }
java
public HashMap<String, String> loadConfig (String node, String object) { HashMap<String, String> data = Maps.newHashMap(); for (ConfigRecord record : from(ConfigRecord.class). where(ConfigRecord.OBJECT.eq(object), ConfigRecord.NODE.eq(node)).select()) { data.put(record.field, record.value); } return data; }
[ "public", "HashMap", "<", "String", ",", "String", ">", "loadConfig", "(", "String", "node", ",", "String", "object", ")", "{", "HashMap", "<", "String", ",", "String", ">", "data", "=", "Maps", ".", "newHashMap", "(", ")", ";", "for", "(", "ConfigReco...
Loads up the configuration data for the specified object. @return a map containing field/value pairs for all stored configuration data.
[ "Loads", "up", "the", "configuration", "data", "for", "the", "specified", "object", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/server/persist/ConfigRepository.java#L51-L59
train
threerings/narya
core/src/main/java/com/threerings/admin/server/persist/ConfigRepository.java
ConfigRepository.updateConfig
public void updateConfig (String node, String object, String field, String value) { store(new ConfigRecord(node, object, field, value)); }
java
public void updateConfig (String node, String object, String field, String value) { store(new ConfigRecord(node, object, field, value)); }
[ "public", "void", "updateConfig", "(", "String", "node", ",", "String", "object", ",", "String", "field", ",", "String", "value", ")", "{", "store", "(", "new", "ConfigRecord", "(", "node", ",", "object", ",", "field", ",", "value", ")", ")", ";", "}" ...
Updates the specified configuration datum.
[ "Updates", "the", "specified", "configuration", "datum", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/server/persist/ConfigRepository.java#L64-L67
train
threerings/narya
core/src/main/java/com/threerings/presents/server/PresentsSession.java
PresentsSession.getInetAddress
public InetAddress getInetAddress () { Connection conn = getConnection(); return (conn == null) ? null : conn.getInetAddress(); }
java
public InetAddress getInetAddress () { Connection conn = getConnection(); return (conn == null) ? null : conn.getInetAddress(); }
[ "public", "InetAddress", "getInetAddress", "(", ")", "{", "Connection", "conn", "=", "getConnection", "(", ")", ";", "return", "(", "conn", "==", "null", ")", "?", "null", ":", "conn", ".", "getInetAddress", "(", ")", ";", "}" ]
Returns the address of the connected client or null if this client is not connected.
[ "Returns", "the", "address", "of", "the", "connected", "client", "or", "null", "if", "this", "client", "is", "not", "connected", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L177-L181
train