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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
aalmiray/Json-lib | src/main/java/net/sf/json/util/JSONUtils.java | JSONUtils.isFloat | private static boolean isFloat( Number n ) {
if( n instanceof Float ){
return true;
}
try{
float f = Float.parseFloat( String.valueOf( n ) );
return !Float.isInfinite( f );
}catch( NumberFormatException e ){
return false;
}
} | java | private static boolean isFloat( Number n ) {
if( n instanceof Float ){
return true;
}
try{
float f = Float.parseFloat( String.valueOf( n ) );
return !Float.isInfinite( f );
}catch( NumberFormatException e ){
return false;
}
} | [
"private",
"static",
"boolean",
"isFloat",
"(",
"Number",
"n",
")",
"{",
"if",
"(",
"n",
"instanceof",
"Float",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"float",
"f",
"=",
"Float",
".",
"parseFloat",
"(",
"String",
".",
"valueOf",
"(",
"n",
... | Finds out if n represents a Float.
@return true if n is instanceOf Float or the literal value can be
evaluated as a Float. | [
"Finds",
"out",
"if",
"n",
"represents",
"a",
"Float",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/util/JSONUtils.java#L819-L829 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/util/JSONUtils.java | JSONUtils.isInteger | private static boolean isInteger( Number n ) {
if( n instanceof Integer ){
return true;
}
try{
Integer.parseInt( String.valueOf( n ) );
return true;
}catch( NumberFormatException e ){
return false;
}
} | java | private static boolean isInteger( Number n ) {
if( n instanceof Integer ){
return true;
}
try{
Integer.parseInt( String.valueOf( n ) );
return true;
}catch( NumberFormatException e ){
return false;
}
} | [
"private",
"static",
"boolean",
"isInteger",
"(",
"Number",
"n",
")",
"{",
"if",
"(",
"n",
"instanceof",
"Integer",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"Integer",
".",
"parseInt",
"(",
"String",
".",
"valueOf",
"(",
"n",
")",
")",
";",
... | Finds out if n represents an Integer.
@return true if n is instanceOf Integer or the literal value can be
evaluated as an Integer. | [
"Finds",
"out",
"if",
"n",
"represents",
"an",
"Integer",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/util/JSONUtils.java#L837-L847 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/util/JSONUtils.java | JSONUtils.isLong | private static boolean isLong( Number n ) {
if( n instanceof Long ){
return true;
}
try{
Long.parseLong( String.valueOf( n ) );
return true;
}catch( NumberFormatException e ){
return false;
}
} | java | private static boolean isLong( Number n ) {
if( n instanceof Long ){
return true;
}
try{
Long.parseLong( String.valueOf( n ) );
return true;
}catch( NumberFormatException e ){
return false;
}
} | [
"private",
"static",
"boolean",
"isLong",
"(",
"Number",
"n",
")",
"{",
"if",
"(",
"n",
"instanceof",
"Long",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"Long",
".",
"parseLong",
"(",
"String",
".",
"valueOf",
"(",
"n",
")",
")",
";",
"retur... | Finds out if n represents a Long.
@return true if n is instanceOf Long or the literal value can be evaluated
as a Long. | [
"Finds",
"out",
"if",
"n",
"represents",
"a",
"Long",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/util/JSONUtils.java#L855-L865 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONFunction.java | JSONFunction.parse | public static JSONFunction parse( String str ) {
if( !JSONUtils.isFunction( str ) ) {
throw new JSONException( "String is not a function. " + str );
} else {
String params = JSONUtils.getFunctionParams( str );
String text = JSONUtils.getFunctionBody( str );
return new JSO... | java | public static JSONFunction parse( String str ) {
if( !JSONUtils.isFunction( str ) ) {
throw new JSONException( "String is not a function. " + str );
} else {
String params = JSONUtils.getFunctionParams( str );
String text = JSONUtils.getFunctionBody( str );
return new JSO... | [
"public",
"static",
"JSONFunction",
"parse",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"!",
"JSONUtils",
".",
"isFunction",
"(",
"str",
")",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"\"String is not a function. \"",
"+",
"str",
")",
";",
"}",
"else... | Constructs a JSONFunction from a text representation | [
"Constructs",
"a",
"JSONFunction",
"from",
"a",
"text",
"representation"
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONFunction.java#L40-L48 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONArray.java | JSONArray.getDimensions | public static int[] getDimensions( JSONArray jsonArray ) {
// short circuit for empty arrays
if( jsonArray == null || jsonArray.isEmpty() ){
return new int[] { 0 };
}
List dims = new ArrayList();
processArrayDimensions( jsonArray, dims, 0 );
int[] dimensions = new int[dims.... | java | public static int[] getDimensions( JSONArray jsonArray ) {
// short circuit for empty arrays
if( jsonArray == null || jsonArray.isEmpty() ){
return new int[] { 0 };
}
List dims = new ArrayList();
processArrayDimensions( jsonArray, dims, 0 );
int[] dimensions = new int[dims.... | [
"public",
"static",
"int",
"[",
"]",
"getDimensions",
"(",
"JSONArray",
"jsonArray",
")",
"{",
"// short circuit for empty arrays",
"if",
"(",
"jsonArray",
"==",
"null",
"||",
"jsonArray",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"new",
"int",
"[",
"]",... | Returns the number of dimensions suited for a java array. | [
"Returns",
"the",
"number",
"of",
"dimensions",
"suited",
"for",
"a",
"java",
"array",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONArray.java#L172-L186 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONArray.java | JSONArray.toArray | public static Object toArray( JSONArray jsonArray, Class objectClass ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( objectClass );
return toArray( jsonArray, jsonConfig );
} | java | public static Object toArray( JSONArray jsonArray, Class objectClass ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( objectClass );
return toArray( jsonArray, jsonConfig );
} | [
"public",
"static",
"Object",
"toArray",
"(",
"JSONArray",
"jsonArray",
",",
"Class",
"objectClass",
")",
"{",
"JsonConfig",
"jsonConfig",
"=",
"new",
"JsonConfig",
"(",
")",
";",
"jsonConfig",
".",
"setRootClass",
"(",
"objectClass",
")",
";",
"return",
"toAr... | Creates a java array from a JSONArray. | [
"Creates",
"a",
"java",
"array",
"from",
"a",
"JSONArray",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONArray.java#L198-L202 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONArray.java | JSONArray.toCollection | public static Collection toCollection( JSONArray jsonArray, Class objectClass ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( objectClass );
return toCollection( jsonArray, jsonConfig );
} | java | public static Collection toCollection( JSONArray jsonArray, Class objectClass ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( objectClass );
return toCollection( jsonArray, jsonConfig );
} | [
"public",
"static",
"Collection",
"toCollection",
"(",
"JSONArray",
"jsonArray",
",",
"Class",
"objectClass",
")",
"{",
"JsonConfig",
"jsonConfig",
"=",
"new",
"JsonConfig",
"(",
")",
";",
"jsonConfig",
".",
"setRootClass",
"(",
"objectClass",
")",
";",
"return"... | Creates a Collection from a JSONArray. | [
"Creates",
"a",
"Collection",
"from",
"a",
"JSONArray",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONArray.java#L335-L339 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONArray.java | JSONArray.toList | public static List toList( JSONArray jsonArray, Class objectClass ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( objectClass );
return toList( jsonArray, jsonConfig );
} | java | public static List toList( JSONArray jsonArray, Class objectClass ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( objectClass );
return toList( jsonArray, jsonConfig );
} | [
"public",
"static",
"List",
"toList",
"(",
"JSONArray",
"jsonArray",
",",
"Class",
"objectClass",
")",
"{",
"JsonConfig",
"jsonConfig",
"=",
"new",
"JsonConfig",
"(",
")",
";",
"jsonConfig",
".",
"setRootClass",
"(",
"objectClass",
")",
";",
"return",
"toList"... | Creates a List from a JSONArray.
@deprecated replaced by toCollection
@see #toCollection(JSONArray,Class) | [
"Creates",
"a",
"List",
"from",
"a",
"JSONArray",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONArray.java#L421-L425 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONArray.java | JSONArray.element | public JSONArray element( Collection value, JsonConfig jsonConfig ) {
if( value instanceof JSONArray ){
elements.add( value );
return this;
}else{
return element( _fromCollection( value, jsonConfig ) );
}
} | java | public JSONArray element( Collection value, JsonConfig jsonConfig ) {
if( value instanceof JSONArray ){
elements.add( value );
return this;
}else{
return element( _fromCollection( value, jsonConfig ) );
}
} | [
"public",
"JSONArray",
"element",
"(",
"Collection",
"value",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"value",
"instanceof",
"JSONArray",
")",
"{",
"elements",
".",
"add",
"(",
"value",
")",
";",
"return",
"this",
";",
"}",
"else",
"{",
"re... | Append a value in the JSONArray, where the value will be a JSONArray which
is produced from a Collection.
@param value A Collection value.
@return this. | [
"Append",
"a",
"value",
"in",
"the",
"JSONArray",
"where",
"the",
"value",
"will",
"be",
"a",
"JSONArray",
"which",
"is",
"produced",
"from",
"a",
"Collection",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONArray.java#L1208-L1215 | train |
aalmiray/Json-lib | src/main/jdk15/net/sf/json/JSONArray.java | JSONArray._fromArray | private static JSONArray _fromArray( Enum e, JsonConfig jsonConfig ) {
if( !addInstance( e ) ){
try{
return jsonConfig.getCycleDetectionStrategy()
.handleRepeatedReferenceAsArray( e );
}catch( JSONException jsone ){
removeInstance( e );
fireE... | java | private static JSONArray _fromArray( Enum e, JsonConfig jsonConfig ) {
if( !addInstance( e ) ){
try{
return jsonConfig.getCycleDetectionStrategy()
.handleRepeatedReferenceAsArray( e );
}catch( JSONException jsone ){
removeInstance( e );
fireE... | [
"private",
"static",
"JSONArray",
"_fromArray",
"(",
"Enum",
"e",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"!",
"addInstance",
"(",
"e",
")",
")",
"{",
"try",
"{",
"return",
"jsonConfig",
".",
"getCycleDetectionStrategy",
"(",
")",
".",
"handl... | Construct a JSONArray from an Enum value.
@param e A enum value.
@throws JSONException If there is a syntax error. | [
"Construct",
"a",
"JSONArray",
"from",
"an",
"Enum",
"value",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/jdk15/net/sf/json/JSONArray.java#L816-L847 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireArrayEndEvent | protected static void fireArrayEndEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next();
... | java | protected static void fireArrayEndEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next();
... | [
"protected",
"static",
"void",
"fireArrayEndEvent",
"(",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
"=",
"jsonConfig",
".",
"getJsonEventListeners",
"(",
... | Fires an end of array event. | [
"Fires",
"an",
"end",
"of",
"array",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L73-L85 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireArrayStartEvent | protected static void fireArrayStartEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next();... | java | protected static void fireArrayStartEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next();... | [
"protected",
"static",
"void",
"fireArrayStartEvent",
"(",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
"=",
"jsonConfig",
".",
"getJsonEventListeners",
"("... | Fires a start of array event. | [
"Fires",
"a",
"start",
"of",
"array",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L90-L102 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireElementAddedEvent | protected static void fireElementAddedEvent( int index, Object element, JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEve... | java | protected static void fireElementAddedEvent( int index, Object element, JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEve... | [
"protected",
"static",
"void",
"fireElementAddedEvent",
"(",
"int",
"index",
",",
"Object",
"element",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
... | Fires an element added event.
@param index the index where the element was added
@param element the added element | [
"Fires",
"an",
"element",
"added",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L110-L122 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireErrorEvent | protected static void fireErrorEvent( JSONException jsone, JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) l... | java | protected static void fireErrorEvent( JSONException jsone, JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) l... | [
"protected",
"static",
"void",
"fireErrorEvent",
"(",
"JSONException",
"jsone",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
"=",
"jsonConfig",
".",
... | Fires an error event.
@param jsone the thrown exception | [
"Fires",
"an",
"error",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L129-L141 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireObjectEndEvent | protected static void fireObjectEndEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next();
... | java | protected static void fireObjectEndEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next();
... | [
"protected",
"static",
"void",
"fireObjectEndEvent",
"(",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
"=",
"jsonConfig",
".",
"getJsonEventListeners",
"(",... | Fires an end of object event. | [
"Fires",
"an",
"end",
"of",
"object",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L146-L158 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireObjectStartEvent | protected static void fireObjectStartEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next()... | java | protected static void fireObjectStartEvent( JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listeners.next()... | [
"protected",
"static",
"void",
"fireObjectStartEvent",
"(",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
"=",
"jsonConfig",
".",
"getJsonEventListeners",
"(... | Fires a start of object event. | [
"Fires",
"a",
"start",
"of",
"object",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L163-L175 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.firePropertySetEvent | protected static void firePropertySetEvent( String key, Object value, boolean accumulated,
JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEvent... | java | protected static void firePropertySetEvent( String key, Object value, boolean accumulated,
JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEvent... | [
"protected",
"static",
"void",
"firePropertySetEvent",
"(",
"String",
"key",
",",
"Object",
"value",
",",
"boolean",
"accumulated",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
... | Fires a property set event.
@param key the name of the property
@param value the value of the property
@param accumulated if the value has been accumulated over 'key' | [
"Fires",
"a",
"property",
"set",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L184-L197 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.fireWarnEvent | protected static void fireWarnEvent( String warning, JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listene... | java | protected static void fireWarnEvent( String warning, JsonConfig jsonConfig ) {
if( jsonConfig.isEventTriggeringEnabled() ){
for( Iterator listeners = jsonConfig.getJsonEventListeners()
.iterator(); listeners.hasNext(); ){
JsonEventListener listener = (JsonEventListener) listene... | [
"protected",
"static",
"void",
"fireWarnEvent",
"(",
"String",
"warning",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"isEventTriggeringEnabled",
"(",
")",
")",
"{",
"for",
"(",
"Iterator",
"listeners",
"=",
"jsonConfig",
".",
"get... | Fires a warning event.
@param warning the warning message | [
"Fires",
"a",
"warning",
"event",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L204-L216 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/AbstractJSON.java | AbstractJSON.removeInstance | protected static void removeInstance( Object instance ) {
Set set = getCycleSet();
set.remove( instance );
if(set.size() == 0) {
cycleSet.remove();
}
} | java | protected static void removeInstance( Object instance ) {
Set set = getCycleSet();
set.remove( instance );
if(set.size() == 0) {
cycleSet.remove();
}
} | [
"protected",
"static",
"void",
"removeInstance",
"(",
"Object",
"instance",
")",
"{",
"Set",
"set",
"=",
"getCycleSet",
"(",
")",
";",
"set",
".",
"remove",
"(",
"instance",
")",
";",
"if",
"(",
"set",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"c... | Removes a reference for cycle detection check. | [
"Removes",
"a",
"reference",
"for",
"cycle",
"detection",
"check",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/AbstractJSON.java#L221-L227 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/processors/JsonVerifier.java | JsonVerifier.isValidJsonValue | public static boolean isValidJsonValue( Object value ) {
if( JSONNull.getInstance()
.equals( value ) || value instanceof JSON || value instanceof Boolean
|| value instanceof Byte || value instanceof Short
|| value instanceof Integer || value instanceof Long || value instanceof ... | java | public static boolean isValidJsonValue( Object value ) {
if( JSONNull.getInstance()
.equals( value ) || value instanceof JSON || value instanceof Boolean
|| value instanceof Byte || value instanceof Short
|| value instanceof Integer || value instanceof Long || value instanceof ... | [
"public",
"static",
"boolean",
"isValidJsonValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"JSONNull",
".",
"getInstance",
"(",
")",
".",
"equals",
"(",
"value",
")",
"||",
"value",
"instanceof",
"JSON",
"||",
"value",
"instanceof",
"Boolean",
"||",
"... | Verifies if value is a valid JSON value.
@param value the value to verify | [
"Verifies",
"if",
"value",
"is",
"a",
"valid",
"JSON",
"value",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/processors/JsonVerifier.java#L39-L50 | train |
aalmiray/Json-lib | src/main/java/net/sf/json/JsonConfig.java | JsonConfig.reset | public void reset() {
excludes = EMPTY_EXCLUDES;
ignoreDefaultExcludes = false;
ignoreTransientFields = false;
ignorePublicFields = true;
javascriptCompliant = false;
javaIdentifierTransformer = DEFAULT_JAVA_IDENTIFIER_TRANSFORMER;
cycleDetectionStrategy = DEFAULT_CYCLE_DETECTI... | java | public void reset() {
excludes = EMPTY_EXCLUDES;
ignoreDefaultExcludes = false;
ignoreTransientFields = false;
ignorePublicFields = true;
javascriptCompliant = false;
javaIdentifierTransformer = DEFAULT_JAVA_IDENTIFIER_TRANSFORMER;
cycleDetectionStrategy = DEFAULT_CYCLE_DETECTI... | [
"public",
"void",
"reset",
"(",
")",
"{",
"excludes",
"=",
"EMPTY_EXCLUDES",
";",
"ignoreDefaultExcludes",
"=",
"false",
";",
"ignoreTransientFields",
"=",
"false",
";",
"ignorePublicFields",
"=",
"true",
";",
"javascriptCompliant",
"=",
"false",
";",
"javaIdentif... | Resets all values to its default state. | [
"Resets",
"all",
"values",
"to",
"its",
"default",
"state",
"."
] | 9e2b3376ee8f511a48aa7ac05f75a7414e02280f | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JsonConfig.java#L928-L967 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikTracker.java | PiwikTracker.sendRequest | public HttpResponse sendRequest(PiwikRequest request) throws IOException{
HttpClient client = getHttpClient();
uriBuilder.replaceQuery(request.getUrlEncodedQueryString());
HttpGet get = new HttpGet(uriBuilder.build());
try {
return client.execute(get);
} finally {
... | java | public HttpResponse sendRequest(PiwikRequest request) throws IOException{
HttpClient client = getHttpClient();
uriBuilder.replaceQuery(request.getUrlEncodedQueryString());
HttpGet get = new HttpGet(uriBuilder.build());
try {
return client.execute(get);
} finally {
... | [
"public",
"HttpResponse",
"sendRequest",
"(",
"PiwikRequest",
"request",
")",
"throws",
"IOException",
"{",
"HttpClient",
"client",
"=",
"getHttpClient",
"(",
")",
";",
"uriBuilder",
".",
"replaceQuery",
"(",
"request",
".",
"getUrlEncodedQueryString",
"(",
")",
"... | Send a request.
@param request request to send
@return the response from this request
@throws IOException thrown if there was a problem with this connection | [
"Send",
"a",
"request",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikTracker.java#L87-L97 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikTracker.java | PiwikTracker.sendBulkRequest | public HttpResponse sendBulkRequest(Iterable<PiwikRequest> requests, String authToken) throws IOException{
if (authToken != null && authToken.length() != PiwikRequest.AUTH_TOKEN_LENGTH){
throw new IllegalArgumentException(authToken+" is not "+PiwikRequest.AUTH_TOKEN_LENGTH+" characters long.");
... | java | public HttpResponse sendBulkRequest(Iterable<PiwikRequest> requests, String authToken) throws IOException{
if (authToken != null && authToken.length() != PiwikRequest.AUTH_TOKEN_LENGTH){
throw new IllegalArgumentException(authToken+" is not "+PiwikRequest.AUTH_TOKEN_LENGTH+" characters long.");
... | [
"public",
"HttpResponse",
"sendBulkRequest",
"(",
"Iterable",
"<",
"PiwikRequest",
">",
"requests",
",",
"String",
"authToken",
")",
"throws",
"IOException",
"{",
"if",
"(",
"authToken",
"!=",
"null",
"&&",
"authToken",
".",
"length",
"(",
")",
"!=",
"PiwikReq... | Send multiple requests in a single HTTP call. More efficient than sending
several individual requests. Specify the AuthToken if parameters that require
an auth token is used.
@param requests the requests to send
@param authToken specify if any of the parameters use require AuthToken
@return the response from these re... | [
"Send",
"multiple",
"requests",
"in",
"a",
"single",
"HTTP",
"call",
".",
"More",
"efficient",
"than",
"sending",
"several",
"individual",
"requests",
".",
"Specify",
"the",
"AuthToken",
"if",
"parameters",
"that",
"require",
"an",
"auth",
"token",
"is",
"used... | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikTracker.java#L119-L147 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikTracker.java | PiwikTracker.getHttpClient | protected HttpClient getHttpClient(){
HttpClientBuilder builder = HttpClientBuilder.create();
if(proxyHost != null && proxyPort != 0) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
... | java | protected HttpClient getHttpClient(){
HttpClientBuilder builder = HttpClientBuilder.create();
if(proxyHost != null && proxyPort != 0) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
... | [
"protected",
"HttpClient",
"getHttpClient",
"(",
")",
"{",
"HttpClientBuilder",
"builder",
"=",
"HttpClientBuilder",
".",
"create",
"(",
")",
";",
"if",
"(",
"proxyHost",
"!=",
"null",
"&&",
"proxyPort",
"!=",
"0",
")",
"{",
"HttpHost",
"proxy",
"=",
"new",
... | Get a HTTP client. With proxy if a proxy is provided in the constructor.
@return a HTTP client | [
"Get",
"a",
"HTTP",
"client",
".",
"With",
"proxy",
"if",
"a",
"proxy",
"is",
"provided",
"in",
"the",
"constructor",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikTracker.java#L153-L171 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/EcommerceItem.java | EcommerceItem.toJsonArray | JsonArray toJsonArray(){
JsonArrayBuilder ab = Json.createArrayBuilder();
ab.add(sku);
ab.add(name);
ab.add(category);
ab.add(price);
ab.add(quantity);
return ab.build();
} | java | JsonArray toJsonArray(){
JsonArrayBuilder ab = Json.createArrayBuilder();
ab.add(sku);
ab.add(name);
ab.add(category);
ab.add(price);
ab.add(quantity);
return ab.build();
} | [
"JsonArray",
"toJsonArray",
"(",
")",
"{",
"JsonArrayBuilder",
"ab",
"=",
"Json",
".",
"createArrayBuilder",
"(",
")",
";",
"ab",
".",
"add",
"(",
"sku",
")",
";",
"ab",
".",
"add",
"(",
"name",
")",
";",
"ab",
".",
"add",
"(",
"category",
")",
";"... | Returns the value of this EcommerceItem as a JsonArray.
@return this as a JsonArray | [
"Returns",
"the",
"value",
"of",
"this",
"EcommerceItem",
"as",
"a",
"JsonArray",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/EcommerceItem.java#L144-L153 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getCustomTrackingParameter | public List getCustomTrackingParameter(String key){
if (key == null){
throw new NullPointerException("Key cannot be null.");
}
List l = customTrackingParameters.get(key);
if (l == null){
return new ArrayList(0);
}
return new ArrayList(l);
} | java | public List getCustomTrackingParameter(String key){
if (key == null){
throw new NullPointerException("Key cannot be null.");
}
List l = customTrackingParameters.get(key);
if (l == null){
return new ArrayList(0);
}
return new ArrayList(l);
} | [
"public",
"List",
"getCustomTrackingParameter",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Key cannot be null.\"",
")",
";",
"}",
"List",
"l",
"=",
"customTrackingParameters",
".",
... | Gets the list of objects currently stored at the specified custom tracking
parameter. An empty list will be returned if there are no objects set at
that key.
@param key the key of the parameter whose list of objects to get. Cannot be null
@return the list of objects currently stored at the specified key | [
"Gets",
"the",
"list",
"of",
"objects",
"currently",
"stored",
"at",
"the",
"specified",
"custom",
"tracking",
"parameter",
".",
"An",
"empty",
"list",
"will",
"be",
"returned",
"if",
"there",
"are",
"no",
"objects",
"set",
"at",
"that",
"key",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L449-L458 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.addCustomTrackingParameter | public void addCustomTrackingParameter(String key, Object value){
if (key == null){
throw new NullPointerException("Key cannot be null.");
}
if (value == null){
throw new NullPointerException("Cannot add a null custom tracking parameter.");
}
else{
... | java | public void addCustomTrackingParameter(String key, Object value){
if (key == null){
throw new NullPointerException("Key cannot be null.");
}
if (value == null){
throw new NullPointerException("Cannot add a null custom tracking parameter.");
}
else{
... | [
"public",
"void",
"addCustomTrackingParameter",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Key cannot be null.\"",
")",
";",
"}",
"if",
"(",
"value",
"==",... | Add a custom tracking parameter to the specified key. This allows users
to have multiple parameters with the same name and different values,
commonly used during situations where list parameters are needed
@param key the parameter's key. Cannot be null
@param value the parameter's value. Cannot be null | [
"Add",
"a",
"custom",
"tracking",
"parameter",
"to",
"the",
"specified",
"key",
".",
"This",
"allows",
"users",
"to",
"have",
"multiple",
"parameters",
"with",
"the",
"same",
"name",
"and",
"different",
"values",
"commonly",
"used",
"during",
"situations",
"wh... | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L490-L505 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setGoalRevenue | public void setGoalRevenue(Double goalRevenue){
if (goalRevenue != null && getGoalId() == null){
throw new IllegalStateException("GoalId must be set before GoalRevenue can be set.");
}
setParameter(GOAL_REVENUE, goalRevenue);
} | java | public void setGoalRevenue(Double goalRevenue){
if (goalRevenue != null && getGoalId() == null){
throw new IllegalStateException("GoalId must be set before GoalRevenue can be set.");
}
setParameter(GOAL_REVENUE, goalRevenue);
} | [
"public",
"void",
"setGoalRevenue",
"(",
"Double",
"goalRevenue",
")",
"{",
"if",
"(",
"goalRevenue",
"!=",
"null",
"&&",
"getGoalId",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"GoalId must be set before GoalRevenue can be set... | Set a monetary value that was generated as revenue by this goal conversion.
Only used if idgoal is specified in the request.
@param goalRevenue the goal revenue to set. A null value will remove this parameter | [
"Set",
"a",
"monetary",
"value",
"that",
"was",
"generated",
"as",
"revenue",
"by",
"this",
"goal",
"conversion",
".",
"Only",
"used",
"if",
"idgoal",
"is",
"specified",
"in",
"the",
"request",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L864-L869 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setPageCustomVariable | @Deprecated
public void setPageCustomVariable(String key, String value){
if (value == null){
removeCustomVariable(PAGE_CUSTOM_VARIABLE, key);
} else {
setCustomVariable(PAGE_CUSTOM_VARIABLE, new CustomVariable(key, value), null);
}
} | java | @Deprecated
public void setPageCustomVariable(String key, String value){
if (value == null){
removeCustomVariable(PAGE_CUSTOM_VARIABLE, key);
} else {
setCustomVariable(PAGE_CUSTOM_VARIABLE, new CustomVariable(key, value), null);
}
} | [
"@",
"Deprecated",
"public",
"void",
"setPageCustomVariable",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"removeCustomVariable",
"(",
"PAGE_CUSTOM_VARIABLE",
",",
"key",
")",
";",
"}",
"else",
"{",
"... | Set a page custom variable with the specified key and value at the first available index.
All page custom variables with this key will be overwritten or deleted
@param key the key of the variable to set
@param value the value of the variable to set at the specified key. A null value will remove this custom variable
@d... | [
"Set",
"a",
"page",
"custom",
"variable",
"with",
"the",
"specified",
"key",
"and",
"value",
"at",
"the",
"first",
"available",
"index",
".",
"All",
"page",
"custom",
"variables",
"with",
"this",
"key",
"will",
"be",
"overwritten",
"or",
"deleted"
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L985-L992 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setSearchCategory | public void setSearchCategory(String searchCategory){
if (searchCategory != null && getSearchQuery() == null){
throw new IllegalStateException("SearchQuery must be set before SearchCategory can be set.");
}
setParameter(SEARCH_CATEGORY, searchCategory);
} | java | public void setSearchCategory(String searchCategory){
if (searchCategory != null && getSearchQuery() == null){
throw new IllegalStateException("SearchQuery must be set before SearchCategory can be set.");
}
setParameter(SEARCH_CATEGORY, searchCategory);
} | [
"public",
"void",
"setSearchCategory",
"(",
"String",
"searchCategory",
")",
"{",
"if",
"(",
"searchCategory",
"!=",
"null",
"&&",
"getSearchQuery",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"SearchQuery must be set before Sea... | Specify a search category with this parameter. SearchQuery must first be
set.
@param searchCategory the search category to set. A null value will remove this parameter | [
"Specify",
"a",
"search",
"category",
"with",
"this",
"parameter",
".",
"SearchQuery",
"must",
"first",
"be",
"set",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1275-L1280 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setUserCustomVariable | @Deprecated
public void setUserCustomVariable(String key, String value){
if (value == null){
removeCustomVariable(VISIT_CUSTOM_VARIABLE, key);
} else {
setCustomVariable(VISIT_CUSTOM_VARIABLE, new CustomVariable(key, value), null);
}
} | java | @Deprecated
public void setUserCustomVariable(String key, String value){
if (value == null){
removeCustomVariable(VISIT_CUSTOM_VARIABLE, key);
} else {
setCustomVariable(VISIT_CUSTOM_VARIABLE, new CustomVariable(key, value), null);
}
} | [
"@",
"Deprecated",
"public",
"void",
"setUserCustomVariable",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"removeCustomVariable",
"(",
"VISIT_CUSTOM_VARIABLE",
",",
"key",
")",
";",
"}",
"else",
"{",
... | Set a visit custom variable with the specified key and value at the first available index.
All visit custom variables with this key will be overwritten or deleted
@param key the key of the variable to set
@param value the value of the variable to set at the specified key. A null value will remove this parameter
@depre... | [
"Set",
"a",
"visit",
"custom",
"variable",
"with",
"the",
"specified",
"key",
"and",
"value",
"at",
"the",
"first",
"available",
"index",
".",
"All",
"visit",
"custom",
"variables",
"with",
"this",
"key",
"will",
"be",
"overwritten",
"or",
"deleted"
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1382-L1389 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getQueryString | public String getQueryString(){
StringBuilder sb = new StringBuilder();
for (Entry<String, Object> parameter : parameters.entrySet()){
if (sb.length() > 0){
sb.append("&");
}
sb.append(parameter.getKey());
sb.append("=");
sb.app... | java | public String getQueryString(){
StringBuilder sb = new StringBuilder();
for (Entry<String, Object> parameter : parameters.entrySet()){
if (sb.length() > 0){
sb.append("&");
}
sb.append(parameter.getKey());
sb.append("=");
sb.app... | [
"public",
"String",
"getQueryString",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"parameter",
":",
"parameters",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"... | Get the query string represented by this object.
@return the query string represented by this object | [
"Get",
"the",
"query",
"string",
"represented",
"by",
"this",
"object",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1666-L1688 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getUrlEncodedQueryString | public String getUrlEncodedQueryString(){
StringBuilder sb = new StringBuilder();
for (Entry<String, Object> parameter : parameters.entrySet()){
if (sb.length() > 0){
sb.append("&");
}
try {
StringBuilder sb2 = new StringBuilder();
... | java | public String getUrlEncodedQueryString(){
StringBuilder sb = new StringBuilder();
for (Entry<String, Object> parameter : parameters.entrySet()){
if (sb.length() > 0){
sb.append("&");
}
try {
StringBuilder sb2 = new StringBuilder();
... | [
"public",
"String",
"getUrlEncodedQueryString",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"parameter",
":",
"parameters",
".",
"entrySet",
"(",
")",
")",
"{",
... | Get the url encoded query string represented by this object.
@return the url encoded query string represented by this object | [
"Get",
"the",
"url",
"encoded",
"query",
"string",
"represented",
"by",
"this",
"object",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1694-L1730 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getRandomHexString | public static String getRandomHexString(int length){
byte[] bytes = new byte[length/2];
new Random().nextBytes(bytes);
return DatatypeConverter.printHexBinary(bytes);
} | java | public static String getRandomHexString(int length){
byte[] bytes = new byte[length/2];
new Random().nextBytes(bytes);
return DatatypeConverter.printHexBinary(bytes);
} | [
"public",
"static",
"String",
"getRandomHexString",
"(",
"int",
"length",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"length",
"/",
"2",
"]",
";",
"new",
"Random",
"(",
")",
".",
"nextBytes",
"(",
"bytes",
")",
";",
"return",
"Data... | Get a random hexadecimal string of a specified length.
@param length length of the string to produce
@return a random string consisting only of hexadecimal characters | [
"Get",
"a",
"random",
"hexadecimal",
"string",
"of",
"a",
"specified",
"length",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1737-L1741 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setParameter | private void setParameter(String key, Object value){
if (value == null){
parameters.remove(key);
}
else{
parameters.put(key, value);
}
} | java | private void setParameter(String key, Object value){
if (value == null){
parameters.remove(key);
}
else{
parameters.put(key, value);
}
} | [
"private",
"void",
"setParameter",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"parameters",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"{",
"parameters",
".",
"put",
"(",
"key",
",",
"... | Set a stored parameter.
@param key the parameter's key
@param value the parameter's value. Removes the parameter if null | [
"Set",
"a",
"stored",
"parameter",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1757-L1764 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setNonEmptyStringParameter | private void setNonEmptyStringParameter(String key, String value){
if (value == null){
parameters.remove(key);
}
else if (value.length() == 0){
throw new IllegalArgumentException("Value cannot be empty.");
}
else{
parameters.put(key, value);
... | java | private void setNonEmptyStringParameter(String key, String value){
if (value == null){
parameters.remove(key);
}
else if (value.length() == 0){
throw new IllegalArgumentException("Value cannot be empty.");
}
else{
parameters.put(key, value);
... | [
"private",
"void",
"setNonEmptyStringParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"parameters",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"if",
"(",
"value",
".",
"length",
"(",... | Set a stored parameter and verify it is a non-empty string.
@param key the parameter's key
@param value the parameter's value. Cannot be the empty. Removes the parameter if null
string | [
"Set",
"a",
"stored",
"parameter",
"and",
"verify",
"it",
"is",
"a",
"non",
"-",
"empty",
"string",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1781-L1791 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getBooleanParameter | private Boolean getBooleanParameter(String key){
Integer i = (Integer)parameters.get(key);
if (i == null){
return null;
}
return i.equals(1);
} | java | private Boolean getBooleanParameter(String key){
Integer i = (Integer)parameters.get(key);
if (i == null){
return null;
}
return i.equals(1);
} | [
"private",
"Boolean",
"getBooleanParameter",
"(",
"String",
"key",
")",
"{",
"Integer",
"i",
"=",
"(",
"Integer",
")",
"parameters",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"i",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"i",
... | Get a stored parameter that is a boolean.
@param key the parameter's key
@return the stored parameter's value | [
"Get",
"a",
"stored",
"parameter",
"that",
"is",
"a",
"boolean",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1798-L1804 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setBooleanParameter | private void setBooleanParameter(String key, Boolean value){
if (value == null){
parameters.remove(key);
}
else if (value){
parameters.put(key, 1);
}
else{
parameters.put(key, 0);
}
} | java | private void setBooleanParameter(String key, Boolean value){
if (value == null){
parameters.remove(key);
}
else if (value){
parameters.put(key, 1);
}
else{
parameters.put(key, 0);
}
} | [
"private",
"void",
"setBooleanParameter",
"(",
"String",
"key",
",",
"Boolean",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"parameters",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"if",
"(",
"value",
")",
"{",
"parameters",
... | Set a stored parameter that is a boolean. This value will be stored as "1"
for true and "0" for false.
@param key the parameter's key
@param value the parameter's value. Removes the parameter if null | [
"Set",
"a",
"stored",
"parameter",
"that",
"is",
"a",
"boolean",
".",
"This",
"value",
"will",
"be",
"stored",
"as",
"1",
"for",
"true",
"and",
"0",
"for",
"false",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1812-L1822 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getCustomVariable | private CustomVariable getCustomVariable(String parameter, int index){
CustomVariableList cvl = (CustomVariableList)parameters.get(parameter);
if (cvl == null){
return null;
}
return cvl.get(index);
} | java | private CustomVariable getCustomVariable(String parameter, int index){
CustomVariableList cvl = (CustomVariableList)parameters.get(parameter);
if (cvl == null){
return null;
}
return cvl.get(index);
} | [
"private",
"CustomVariable",
"getCustomVariable",
"(",
"String",
"parameter",
",",
"int",
"index",
")",
"{",
"CustomVariableList",
"cvl",
"=",
"(",
"CustomVariableList",
")",
"parameters",
".",
"get",
"(",
"parameter",
")",
";",
"if",
"(",
"cvl",
"==",
"null",... | Get a value that is stored in a json object at the specified parameter.
@param parameter the parameter to retrieve the json object from
@param key the key of the value. Cannot be null
@return the value | [
"Get",
"a",
"value",
"that",
"is",
"stored",
"in",
"a",
"json",
"object",
"at",
"the",
"specified",
"parameter",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1830-L1837 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.setCustomVariable | private void setCustomVariable(String parameter, CustomVariable customVariable, Integer index){
CustomVariableList cvl = (CustomVariableList)parameters.get(parameter);
if (cvl == null){
cvl = new CustomVariableList();
parameters.put(parameter, cvl);
}
if ... | java | private void setCustomVariable(String parameter, CustomVariable customVariable, Integer index){
CustomVariableList cvl = (CustomVariableList)parameters.get(parameter);
if (cvl == null){
cvl = new CustomVariableList();
parameters.put(parameter, cvl);
}
if ... | [
"private",
"void",
"setCustomVariable",
"(",
"String",
"parameter",
",",
"CustomVariable",
"customVariable",
",",
"Integer",
"index",
")",
"{",
"CustomVariableList",
"cvl",
"=",
"(",
"CustomVariableList",
")",
"parameters",
".",
"get",
"(",
"parameter",
")",
";",
... | Store a value in a json object at the specified parameter.
@param parameter the parameter to store the json object at
@param key the key of the value. Cannot be null
@param value the value. Removes the parameter if null | [
"Store",
"a",
"value",
"in",
"a",
"json",
"object",
"at",
"the",
"specified",
"parameter",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1858-L1877 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.getFromJsonArray | private JsonValue getFromJsonArray(String key, int index){
PiwikJsonArray a = (PiwikJsonArray)parameters.get(key);
if (a == null){
return null;
}
return a.get(index);
} | java | private JsonValue getFromJsonArray(String key, int index){
PiwikJsonArray a = (PiwikJsonArray)parameters.get(key);
if (a == null){
return null;
}
return a.get(index);
} | [
"private",
"JsonValue",
"getFromJsonArray",
"(",
"String",
"key",
",",
"int",
"index",
")",
"{",
"PiwikJsonArray",
"a",
"=",
"(",
"PiwikJsonArray",
")",
"parameters",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"return",
"... | Get the value at the specified index from the json array at the specified
parameter.
@param key the key of the json array to access
@param index the index of the value in the json array
@return the value at the index in the json array | [
"Get",
"the",
"value",
"at",
"the",
"specified",
"index",
"from",
"the",
"json",
"array",
"at",
"the",
"specified",
"parameter",
"."
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1899-L1906 | train |
matomo-org/piwik-java-tracker | src/main/java/org/piwik/java/tracking/PiwikRequest.java | PiwikRequest.addToJsonArray | private void addToJsonArray(String key, JsonValue value){
if (value == null){
throw new NullPointerException("Value cannot be null.");
}
PiwikJsonArray a = (PiwikJsonArray)parameters.get(key);
if (a == null){
a = new PiwikJsonArray();
paramete... | java | private void addToJsonArray(String key, JsonValue value){
if (value == null){
throw new NullPointerException("Value cannot be null.");
}
PiwikJsonArray a = (PiwikJsonArray)parameters.get(key);
if (a == null){
a = new PiwikJsonArray();
paramete... | [
"private",
"void",
"addToJsonArray",
"(",
"String",
"key",
",",
"JsonValue",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Value cannot be null.\"",
")",
";",
"}",
"PiwikJsonArray",
"a",
"=",
"... | Add a value to the json array at the specified parameter
@param key the key of the json array to add to
@param value the value to add. Cannot be null | [
"Add",
"a",
"value",
"to",
"the",
"json",
"array",
"at",
"the",
"specified",
"parameter"
] | 23df71d27a89e89dc7a539b2eda88c90a206458b | https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikRequest.java#L1912-L1923 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/cassandra/io/compress/CompressionMetadata.java | CompressionMetadata.readChunkOffsets | private Memory readChunkOffsets(DataInput input) {
try {
int chunkCount = input.readInt();
Memory offsets = Memory.allocate(chunkCount * 8);
for (int i = 0; i < chunkCount; i++) {
try {
offsets.setLong(i * 8, input.readLong());
... | java | private Memory readChunkOffsets(DataInput input) {
try {
int chunkCount = input.readInt();
Memory offsets = Memory.allocate(chunkCount * 8);
for (int i = 0; i < chunkCount; i++) {
try {
offsets.setLong(i * 8, input.readLong());
... | [
"private",
"Memory",
"readChunkOffsets",
"(",
"DataInput",
"input",
")",
"{",
"try",
"{",
"int",
"chunkCount",
"=",
"input",
".",
"readInt",
"(",
")",
";",
"Memory",
"offsets",
"=",
"Memory",
".",
"allocate",
"(",
"chunkCount",
"*",
"8",
")",
";",
"for",... | Read offsets of the individual chunks from the given input.
@param input Source of the data.
@return collection of the chunk offsets. | [
"Read",
"offsets",
"of",
"the",
"individual",
"chunks",
"from",
"the",
"given",
"input",
"."
] | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/cassandra/io/compress/CompressionMetadata.java#L136-L155 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/sstable/index/SSTableIndexIndex.java | SSTableIndexIndex.readIndex | public static SSTableIndexIndex readIndex(final FileSystem fileSystem, final Path sstablePath) throws IOException {
final Closer closer = Closer.create();
final Path indexPath = sstablePath.suffix(SSTABLE_INDEX_SUFFIX);
// Detonate if we don't have an index.
final FSDataInputStream inpu... | java | public static SSTableIndexIndex readIndex(final FileSystem fileSystem, final Path sstablePath) throws IOException {
final Closer closer = Closer.create();
final Path indexPath = sstablePath.suffix(SSTABLE_INDEX_SUFFIX);
// Detonate if we don't have an index.
final FSDataInputStream inpu... | [
"public",
"static",
"SSTableIndexIndex",
"readIndex",
"(",
"final",
"FileSystem",
"fileSystem",
",",
"final",
"Path",
"sstablePath",
")",
"throws",
"IOException",
"{",
"final",
"Closer",
"closer",
"=",
"Closer",
".",
"create",
"(",
")",
";",
"final",
"Path",
"... | Read an existing index. Reads and returns the index index, which is a list of chunks defined by the Cassandra
Index.db file along with the configured split size.
@param fileSystem Hadoop file system.
@param sstablePath SSTable Index.db.
@return Index of chunks.
@throws IOException | [
"Read",
"an",
"existing",
"index",
".",
"Reads",
"and",
"returns",
"the",
"index",
"index",
"which",
"is",
"a",
"list",
"of",
"chunks",
"defined",
"by",
"the",
"Cassandra",
"Index",
".",
"db",
"file",
"along",
"with",
"the",
"configured",
"split",
"size",
... | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/sstable/index/SSTableIndexIndex.java#L52-L69 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/sstable/index/SSTableIndexOutputFormat.java | SSTableIndexOutputFormat.getOutputCommitter | @Override
public OutputCommitter getOutputCommitter(TaskAttemptContext taskAttemptContext)
throws IOException, InterruptedException {
return new OutputCommitter() {
@Override
public void setupJob(JobContext jobContext) throws IOException {
}
@Over... | java | @Override
public OutputCommitter getOutputCommitter(TaskAttemptContext taskAttemptContext)
throws IOException, InterruptedException {
return new OutputCommitter() {
@Override
public void setupJob(JobContext jobContext) throws IOException {
}
@Over... | [
"@",
"Override",
"public",
"OutputCommitter",
"getOutputCommitter",
"(",
"TaskAttemptContext",
"taskAttemptContext",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"return",
"new",
"OutputCommitter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"... | and writes to that instead. | [
"and",
"writes",
"to",
"that",
"instead",
"."
] | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/sstable/index/SSTableIndexOutputFormat.java#L26-L55 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/sstable/util/CQLUtil.java | CQLUtil.parseCreateStatement | public static CFMetaData parseCreateStatement(String cql) throws RequestValidationException {
final CreateColumnFamilyStatement statement =
(CreateColumnFamilyStatement) QueryProcessor.parseStatement(cql).prepare().statement;
final CFMetaData cfm =
new CFMetaData("assess... | java | public static CFMetaData parseCreateStatement(String cql) throws RequestValidationException {
final CreateColumnFamilyStatement statement =
(CreateColumnFamilyStatement) QueryProcessor.parseStatement(cql).prepare().statement;
final CFMetaData cfm =
new CFMetaData("assess... | [
"public",
"static",
"CFMetaData",
"parseCreateStatement",
"(",
"String",
"cql",
")",
"throws",
"RequestValidationException",
"{",
"final",
"CreateColumnFamilyStatement",
"statement",
"=",
"(",
"CreateColumnFamilyStatement",
")",
"QueryProcessor",
".",
"parseStatement",
"(",... | Parses a CQL CREATE statement into its CFMetaData object
@param cql
@return CFMetaData
@throws RequestValidationException if CQL is invalid | [
"Parses",
"a",
"CQL",
"CREATE",
"statement",
"into",
"its",
"CFMetaData",
"object"
] | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/sstable/util/CQLUtil.java#L22-L31 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/sstable/hadoop/IndexOffsetScanner.java | IndexOffsetScanner.next | public long next() {
try {
ByteBufferUtil.readWithShortLength(input);
final long offset = input.readLong();
// TODO: Because this is version ic > ia promotedIndex is true and we need to handle it. See C* Descriptor
skipPromotedIndex(input);
return o... | java | public long next() {
try {
ByteBufferUtil.readWithShortLength(input);
final long offset = input.readLong();
// TODO: Because this is version ic > ia promotedIndex is true and we need to handle it. See C* Descriptor
skipPromotedIndex(input);
return o... | [
"public",
"long",
"next",
"(",
")",
"{",
"try",
"{",
"ByteBufferUtil",
".",
"readWithShortLength",
"(",
"input",
")",
";",
"final",
"long",
"offset",
"=",
"input",
".",
"readLong",
"(",
")",
";",
"// TODO: Because this is version ic > ia promotedIndex is true and we... | Get the next offset from the SSTable index.
@return SSTable offset. | [
"Get",
"the",
"next",
"offset",
"from",
"the",
"SSTable",
"index",
"."
] | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/sstable/hadoop/IndexOffsetScanner.java#L115-L128 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/sstable/hadoop/IndexOffsetScanner.java | IndexOffsetScanner.skipPromotedIndex | private void skipPromotedIndex(final DataInput in) throws IOException {
final int size = in.readInt();
if (size <= 0) {
return;
}
FileUtils.skipBytesFully(in, size);
} | java | private void skipPromotedIndex(final DataInput in) throws IOException {
final int size = in.readInt();
if (size <= 0) {
return;
}
FileUtils.skipBytesFully(in, size);
} | [
"private",
"void",
"skipPromotedIndex",
"(",
"final",
"DataInput",
"in",
")",
"throws",
"IOException",
"{",
"final",
"int",
"size",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"FileUtils",
".",
... | Convenience method for skipping promoted index from SSTable index file.
@param in DataInput.
@throws IOException | [
"Convenience",
"method",
"for",
"skipping",
"promoted",
"index",
"from",
"SSTable",
"index",
"file",
"."
] | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/sstable/hadoop/IndexOffsetScanner.java#L135-L142 | train |
fullcontact/hadoop-sstable | sstable-core/src/main/java/com/fullcontact/sstable/hadoop/mapreduce/SSTableInputFormat.java | SSTableInputFormat.handleFile | private Collection<FileStatus> handleFile(final FileStatus file, final JobContext job) throws IOException {
final List<FileStatus> results = Lists.newArrayList();
if(file.isDir()) {
final Path p = file.getPath();
LOG.debug("Expanding {}", p);
final FileSystem fs = p.... | java | private Collection<FileStatus> handleFile(final FileStatus file, final JobContext job) throws IOException {
final List<FileStatus> results = Lists.newArrayList();
if(file.isDir()) {
final Path p = file.getPath();
LOG.debug("Expanding {}", p);
final FileSystem fs = p.... | [
"private",
"Collection",
"<",
"FileStatus",
">",
"handleFile",
"(",
"final",
"FileStatus",
"file",
",",
"final",
"JobContext",
"job",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"FileStatus",
">",
"results",
"=",
"Lists",
".",
"newArrayList",
"(",... | If we have a directory recursively gather the files we care about for this job.
@param file Root file/directory.
@param job Job context.
@return All files we care about.
@throws IOException | [
"If",
"we",
"have",
"a",
"directory",
"recursively",
"gather",
"the",
"files",
"we",
"care",
"about",
"for",
"this",
"job",
"."
] | 1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2 | https://github.com/fullcontact/hadoop-sstable/blob/1189c2cb3a2cbbe03b75fda1cf02698e6283dfb2/sstable-core/src/main/java/com/fullcontact/sstable/hadoop/mapreduce/SSTableInputFormat.java#L103-L119 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasherContainer.java | SipHasherContainer.hash | public final long hash(byte[] data, int c, int d) {
return SipHasher.hash(
c, d,
this.v0,
this.v1,
this.v2,
this.v3,
data
);
} | java | public final long hash(byte[] data, int c, int d) {
return SipHasher.hash(
c, d,
this.v0,
this.v1,
this.v2,
this.v3,
data
);
} | [
"public",
"final",
"long",
"hash",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"c",
",",
"int",
"d",
")",
"{",
"return",
"SipHasher",
".",
"hash",
"(",
"c",
",",
"d",
",",
"this",
".",
"v0",
",",
"this",
".",
"v1",
",",
"this",
".",
"v2",
",",... | Hashes input data using the preconfigured state.
@param data
the data to hash and digest.
@param c
the desired rounds of C compression.
@param d
the desired rounds of D compression.
@return
a long value as the output of the hash. | [
"Hashes",
"input",
"data",
"using",
"the",
"preconfigured",
"state",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasherContainer.java#L78-L87 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasherStream.java | SipHasherStream.update | public final SipHasherStream update(byte b) {
this.len++;
this.m |= (((long) b & 0xff) << (this.m_idx++ * 8));
if (this.m_idx < 8) {
return this;
}
this.v3 ^= this.m;
for (int i = 0; i < this.c; i++) {
round();
}
this.v0 ^= this.m;
... | java | public final SipHasherStream update(byte b) {
this.len++;
this.m |= (((long) b & 0xff) << (this.m_idx++ * 8));
if (this.m_idx < 8) {
return this;
}
this.v3 ^= this.m;
for (int i = 0; i < this.c; i++) {
round();
}
this.v0 ^= this.m;
... | [
"public",
"final",
"SipHasherStream",
"update",
"(",
"byte",
"b",
")",
"{",
"this",
".",
"len",
"++",
";",
"this",
".",
"m",
"|=",
"(",
"(",
"(",
"long",
")",
"b",
"&",
"0xff",
")",
"<<",
"(",
"this",
".",
"m_idx",
"++",
"*",
"8",
")",
")",
"... | Updates the hash with a single byte.
This will only modify the internal `m` value, nothing will be modified
in the actual `v*` states until an 8-byte block has been provided.
@param b
the byte being added to the digest.
@return
the same {@link SipHasherStream} for chaining. | [
"Updates",
"the",
"hash",
"with",
"a",
"single",
"byte",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasherStream.java#L106-L120 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasherStream.java | SipHasherStream.digest | public final long digest() {
byte msgLenMod256 = this.len;
while (this.m_idx < 7) {
update((byte) 0);
}
update(msgLenMod256);
this.v2 ^= 0xff;
for (int i = 0; i < this.d; i++) {
round();
}
return this.v0 ^ this.v1 ^ this.v2 ^ thi... | java | public final long digest() {
byte msgLenMod256 = this.len;
while (this.m_idx < 7) {
update((byte) 0);
}
update(msgLenMod256);
this.v2 ^= 0xff;
for (int i = 0; i < this.d; i++) {
round();
}
return this.v0 ^ this.v1 ^ this.v2 ^ thi... | [
"public",
"final",
"long",
"digest",
"(",
")",
"{",
"byte",
"msgLenMod256",
"=",
"this",
".",
"len",
";",
"while",
"(",
"this",
".",
"m_idx",
"<",
"7",
")",
"{",
"update",
"(",
"(",
"byte",
")",
"0",
")",
";",
"}",
"update",
"(",
"msgLenMod256",
... | Finalizes the digest and returns the hash.
This works by padding to the next 8-byte block, before applying
the compression rounds once more - but this time using D rounds
of compression rather than C.
@return
the final result of the hash as a long. | [
"Finalizes",
"the",
"digest",
"and",
"returns",
"the",
"hash",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasherStream.java#L147-L161 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasherStream.java | SipHasherStream.round | private void round() {
this.v0 += this.v1;
this.v2 += this.v3;
this.v1 = rotateLeft(this.v1, 13);
this.v3 = rotateLeft(this.v3, 16);
this.v1 ^= this.v0;
this.v3 ^= this.v2;
this.v0 = rotateLeft(this.v0, 32);
this.v2 += this.v1;
this.v0 += this.v3... | java | private void round() {
this.v0 += this.v1;
this.v2 += this.v3;
this.v1 = rotateLeft(this.v1, 13);
this.v3 = rotateLeft(this.v3, 16);
this.v1 ^= this.v0;
this.v3 ^= this.v2;
this.v0 = rotateLeft(this.v0, 32);
this.v2 += this.v1;
this.v0 += this.v3... | [
"private",
"void",
"round",
"(",
")",
"{",
"this",
".",
"v0",
"+=",
"this",
".",
"v1",
";",
"this",
".",
"v2",
"+=",
"this",
".",
"v3",
";",
"this",
".",
"v1",
"=",
"rotateLeft",
"(",
"this",
".",
"v1",
",",
"13",
")",
";",
"this",
".",
"v3",... | SipRound implementation for internal use. | [
"SipRound",
"implementation",
"for",
"internal",
"use",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasherStream.java#L166-L184 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasher.java | SipHasher.hash | public static long hash(byte[] key, byte[] data, int c, int d) {
if (key.length != 16) {
throw new IllegalArgumentException("Key must be exactly 16 bytes!");
}
long k0 = bytesToLong(key, 0);
long k1 = bytesToLong(key, 8);
return hash(
c, d,
I... | java | public static long hash(byte[] key, byte[] data, int c, int d) {
if (key.length != 16) {
throw new IllegalArgumentException("Key must be exactly 16 bytes!");
}
long k0 = bytesToLong(key, 0);
long k1 = bytesToLong(key, 8);
return hash(
c, d,
I... | [
"public",
"static",
"long",
"hash",
"(",
"byte",
"[",
"]",
"key",
",",
"byte",
"[",
"]",
"data",
",",
"int",
"c",
",",
"int",
"d",
")",
"{",
"if",
"(",
"key",
".",
"length",
"!=",
"16",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"... | Hashes a data input for a given key, using the provided rounds
of compression.
@param key
the key to seed the hash with.
@param data
the input data to hash.
@param c
the number of C rounds of compression
@param d
the number of D rounds of compression.
@return
a long value as the output of the hash. | [
"Hashes",
"a",
"data",
"input",
"for",
"a",
"given",
"key",
"using",
"the",
"provided",
"rounds",
"of",
"compression",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasher.java#L103-L119 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasher.java | SipHasher.toHexString | public static String toHexString(long hash) {
String hex = Long.toHexString(hash);
if (hex.length() == 16) {
return hex;
}
StringBuilder sb = new StringBuilder();
for (int i = 0, j = 16 - hex.length(); i < j; i++) {
sb.append('0');
}
ret... | java | public static String toHexString(long hash) {
String hex = Long.toHexString(hash);
if (hex.length() == 16) {
return hex;
}
StringBuilder sb = new StringBuilder();
for (int i = 0, j = 16 - hex.length(); i < j; i++) {
sb.append('0');
}
ret... | [
"public",
"static",
"String",
"toHexString",
"(",
"long",
"hash",
")",
"{",
"String",
"hex",
"=",
"Long",
".",
"toHexString",
"(",
"hash",
")",
";",
"if",
"(",
"hex",
".",
"length",
"(",
")",
"==",
"16",
")",
"{",
"return",
"hex",
";",
"}",
"String... | Converts a hash to a hexidecimal representation.
@param hash
the finalized hash value to convert to hex.
@return
a {@link String} representation of the hash. | [
"Converts",
"a",
"hash",
"to",
"a",
"hexidecimal",
"representation",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasher.java#L162-L175 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasher.java | SipHasher.bytesToLong | static long bytesToLong(byte[] bytes, int offset) {
long m = 0;
for (int i = 0; i < 8; i++) {
m |= ((((long) bytes[i + offset]) & 0xff) << (8 * i));
}
return m;
} | java | static long bytesToLong(byte[] bytes, int offset) {
long m = 0;
for (int i = 0; i < 8; i++) {
m |= ((((long) bytes[i + offset]) & 0xff) << (8 * i));
}
return m;
} | [
"static",
"long",
"bytesToLong",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
")",
"{",
"long",
"m",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"m",
"|=",
"(",
"(",
"(",
"(",
"l... | Converts a chunk of 8 bytes to a number in little endian.
Accepts an offset to determine where the chunk begins.
@param bytes
the byte array containing our bytes to convert.
@param offset
the index to start at when chunking bytes.
@return
a long representation, in little endian. | [
"Converts",
"a",
"chunk",
"of",
"8",
"bytes",
"to",
"a",
"number",
"in",
"little",
"endian",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasher.java#L189-L195 | train |
whitfin/siphash-java | src/main/java/io/whitfin/siphash/SipHasher.java | SipHasher.hash | static long hash(int c, int d, long v0, long v1, long v2, long v3, byte[] data) {
long m;
int last = data.length / 8 * 8;
int i = 0;
int r;
while (i < last) {
m = data[i++] & 0xffL;
for (r = 1; r < 8; r++) {
m |= (data[i++] & 0xffL) << (r ... | java | static long hash(int c, int d, long v0, long v1, long v2, long v3, byte[] data) {
long m;
int last = data.length / 8 * 8;
int i = 0;
int r;
while (i < last) {
m = data[i++] & 0xffL;
for (r = 1; r < 8; r++) {
m |= (data[i++] & 0xffL) << (r ... | [
"static",
"long",
"hash",
"(",
"int",
"c",
",",
"int",
"d",
",",
"long",
"v0",
",",
"long",
"v1",
",",
"long",
"v2",
",",
"long",
"v3",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"long",
"m",
";",
"int",
"last",
"=",
"data",
".",
"length",
"/",... | Internal 0A hashing implementation.
Requires initial state being manually provided (to avoid allocation). The
compression rounds must also be provided, as nothing will be validated in
this layer (such as defaults).
@param c
the rounds of C compression to apply.
@param d
the rounds of D compression to apply.
@param v0... | [
"Internal",
"0A",
"hashing",
"implementation",
"."
] | 0744d68238bf6d0258154a8152bf2f4537b3cbb8 | https://github.com/whitfin/siphash-java/blob/0744d68238bf6d0258154a8152bf2f4537b3cbb8/src/main/java/io/whitfin/siphash/SipHasher.java#L221-L307 | train |
nathanmarz/dfs-datastores | dfs-datastores/src/main/java/com/backtype/support/SubsetSum.java | SubsetSum.split | public static <T extends Value> List<List<T>> split(List<T> input, long targetSize) {
Collections.sort(input, new Comparator<Value>() {
public int compare(Value o1, Value o2) {
return new Long(o1.getValue()).compareTo(new Long(o2.getValue()));
}
});
List<T... | java | public static <T extends Value> List<List<T>> split(List<T> input, long targetSize) {
Collections.sort(input, new Comparator<Value>() {
public int compare(Value o1, Value o2) {
return new Long(o1.getValue()).compareTo(new Long(o2.getValue()));
}
});
List<T... | [
"public",
"static",
"<",
"T",
"extends",
"Value",
">",
"List",
"<",
"List",
"<",
"T",
">",
">",
"split",
"(",
"List",
"<",
"T",
">",
"input",
",",
"long",
"targetSize",
")",
"{",
"Collections",
".",
"sort",
"(",
"input",
",",
"new",
"Comparator",
"... | things that are too big get their own set | [
"things",
"that",
"are",
"too",
"big",
"get",
"their",
"own",
"set"
] | ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e | https://github.com/nathanmarz/dfs-datastores/blob/ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e/dfs-datastores/src/main/java/com/backtype/support/SubsetSum.java#L54-L80 | train |
nathanmarz/dfs-datastores | dfs-datastores/src/main/java/com/backtype/hadoop/pail/Pail.java | Pail.checkCombineValidity | private boolean checkCombineValidity(Pail p, CopyArgs args) throws IOException {
if(args.force) return true;
PailSpec mine = getSpec();
PailSpec other = p.getSpec();
PailStructure structure = mine.getStructure();
boolean typesSame = structure.getType().equals(other.getStructure(... | java | private boolean checkCombineValidity(Pail p, CopyArgs args) throws IOException {
if(args.force) return true;
PailSpec mine = getSpec();
PailSpec other = p.getSpec();
PailStructure structure = mine.getStructure();
boolean typesSame = structure.getType().equals(other.getStructure(... | [
"private",
"boolean",
"checkCombineValidity",
"(",
"Pail",
"p",
",",
"CopyArgs",
"args",
")",
"throws",
"IOException",
"{",
"if",
"(",
"args",
".",
"force",
")",
"return",
"true",
";",
"PailSpec",
"mine",
"=",
"getSpec",
"(",
")",
";",
"PailSpec",
"other",... | returns if formats are same | [
"returns",
"if",
"formats",
"are",
"same"
] | ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e | https://github.com/nathanmarz/dfs-datastores/blob/ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e/dfs-datastores/src/main/java/com/backtype/hadoop/pail/Pail.java#L312-L330 | train |
nathanmarz/dfs-datastores | dfs-datastores/src/main/java/com/backtype/hadoop/pail/Pail.java | Pail.copyAppend | public void copyAppend(Pail p, CopyArgs args) throws IOException {
args = new CopyArgs(args);
if(args.renameMode==null) args.renameMode = RenameMode.ALWAYS_RENAME;
boolean formatsSame = checkCombineValidity(p, args);
String sourceQual = getQualifiedRoot(p);
String destQual = get... | java | public void copyAppend(Pail p, CopyArgs args) throws IOException {
args = new CopyArgs(args);
if(args.renameMode==null) args.renameMode = RenameMode.ALWAYS_RENAME;
boolean formatsSame = checkCombineValidity(p, args);
String sourceQual = getQualifiedRoot(p);
String destQual = get... | [
"public",
"void",
"copyAppend",
"(",
"Pail",
"p",
",",
"CopyArgs",
"args",
")",
"throws",
"IOException",
"{",
"args",
"=",
"new",
"CopyArgs",
"(",
"args",
")",
";",
"if",
"(",
"args",
".",
"renameMode",
"==",
"null",
")",
"args",
".",
"renameMode",
"="... | Copy append will copy all the files from p into this pail. Appending maintains the
structure that was present in p. | [
"Copy",
"append",
"will",
"copy",
"all",
"the",
"files",
"from",
"p",
"into",
"this",
"pail",
".",
"Appending",
"maintains",
"the",
"structure",
"that",
"was",
"present",
"in",
"p",
"."
] | ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e | https://github.com/nathanmarz/dfs-datastores/blob/ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e/dfs-datastores/src/main/java/com/backtype/hadoop/pail/Pail.java#L411-L423 | train |
nathanmarz/dfs-datastores | dfs-datastores/src/main/java/com/backtype/support/Utils.java | Utils.isLong | public static boolean isLong(String input) {
try {
Long.parseLong(input);
return true;
} catch (Exception e) {
return false;
}
} | java | public static boolean isLong(String input) {
try {
Long.parseLong(input);
return true;
} catch (Exception e) {
return false;
}
} | [
"public",
"static",
"boolean",
"isLong",
"(",
"String",
"input",
")",
"{",
"try",
"{",
"Long",
".",
"parseLong",
"(",
"input",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Return true or false if the input is a long
@param input
@return boolean | [
"Return",
"true",
"or",
"false",
"if",
"the",
"input",
"is",
"a",
"long"
] | ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e | https://github.com/nathanmarz/dfs-datastores/blob/ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e/dfs-datastores/src/main/java/com/backtype/support/Utils.java#L42-L49 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java | HtmlParser.parseAnnotatableText | private void parseAnnotatableText(String text, Element parent) {
AnnotationNode annotation = null;
Matcher matcher = AnnotationParser.WIDGET_ANNOTATION_REGEX.matcher(text);
int previousEnd = 0;
while (matcher.find()){
int start = matcher.start();
// build a new text node for what is between last i... | java | private void parseAnnotatableText(String text, Element parent) {
AnnotationNode annotation = null;
Matcher matcher = AnnotationParser.WIDGET_ANNOTATION_REGEX.matcher(text);
int previousEnd = 0;
while (matcher.find()){
int start = matcher.start();
// build a new text node for what is between last i... | [
"private",
"void",
"parseAnnotatableText",
"(",
"String",
"text",
",",
"Element",
"parent",
")",
"{",
"AnnotationNode",
"annotation",
"=",
"null",
";",
"Matcher",
"matcher",
"=",
"AnnotationParser",
".",
"WIDGET_ANNOTATION_REGEX",
".",
"matcher",
"(",
"text",
")",... | Pulls a text segment apart by annotations within it and creates multiple Text Nodes
applying the annotation to each text segment as approriate.
@param text the text to be processed for annotations
@param parent | [
"Pulls",
"a",
"text",
"segment",
"apart",
"by",
"annotations",
"within",
"it",
"and",
"creates",
"multiple",
"Text",
"Nodes",
"applying",
"the",
"annotation",
"to",
"each",
"text",
"segment",
"as",
"approriate",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java#L265-L320 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java | HtmlParser.addTextNodeToParent | private void addTextNodeToParent (String text, Element parent, AnnotationNode annotation) {
String [] lines = new String[] {text};
if (annotation != null)
lines = splitInTwo(text);
for (int i = 0; i < lines.length; i++){
TextNode textNode = TextNode.createFromEncoded(lines[i], baseUri);
lin... | java | private void addTextNodeToParent (String text, Element parent, AnnotationNode annotation) {
String [] lines = new String[] {text};
if (annotation != null)
lines = splitInTwo(text);
for (int i = 0; i < lines.length; i++){
TextNode textNode = TextNode.createFromEncoded(lines[i], baseUri);
lin... | [
"private",
"void",
"addTextNodeToParent",
"(",
"String",
"text",
",",
"Element",
"parent",
",",
"AnnotationNode",
"annotation",
")",
"{",
"String",
"[",
"]",
"lines",
"=",
"new",
"String",
"[",
"]",
"{",
"text",
"}",
";",
"if",
"(",
"annotation",
"!=",
"... | Break the text up by the first line delimiter. We only want annotations applied to the first line of a block of text
and not to a whole segment.
@param text the text to turn into nodes
@param parent the parent node
@param annotation the current annotation to be applied to the first line of text | [
"Break",
"the",
"text",
"up",
"by",
"the",
"first",
"line",
"delimiter",
".",
"We",
"only",
"want",
"annotations",
"applied",
"to",
"the",
"first",
"line",
"of",
"a",
"block",
"of",
"text",
"and",
"not",
"to",
"a",
"whole",
"segment",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java#L330-L347 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java | HtmlParser.splitInTwo | private String[] splitInTwo(String text) {
Matcher matcher = LINE_SEPARATOR.matcher(text);
while (matcher.find()){
int start = matcher.start();
if (start > 0 && start < text.length()) {
String segment = text.substring(0, start);
if (segment.trim().length() > 0)
return new String[] {text.su... | java | private String[] splitInTwo(String text) {
Matcher matcher = LINE_SEPARATOR.matcher(text);
while (matcher.find()){
int start = matcher.start();
if (start > 0 && start < text.length()) {
String segment = text.substring(0, start);
if (segment.trim().length() > 0)
return new String[] {text.su... | [
"private",
"String",
"[",
"]",
"splitInTwo",
"(",
"String",
"text",
")",
"{",
"Matcher",
"matcher",
"=",
"LINE_SEPARATOR",
".",
"matcher",
"(",
"text",
")",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"int",
"start",
"=",
"matcher",
... | Break a text segment apart into two at the first line delimiter which has non-whitespace characters before it.
@param text text to split in two
@return | [
"Break",
"a",
"text",
"segment",
"apart",
"into",
"two",
"at",
"the",
"first",
"line",
"delimiter",
"which",
"has",
"non",
"-",
"whitespace",
"characters",
"before",
"it",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java#L355-L366 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java | HtmlParser.canContain | boolean canContain(Tag parent, Tag child) {
Validate.notNull(child);
if (child.isBlock() && !parent.canContainBlock())
return false;
if (!child.isBlock() && parent.isData())
return false;
if (closingOptional.contains(parent.getName()) && parent.getName().equals(child.getName()))
ret... | java | boolean canContain(Tag parent, Tag child) {
Validate.notNull(child);
if (child.isBlock() && !parent.canContainBlock())
return false;
if (!child.isBlock() && parent.isData())
return false;
if (closingOptional.contains(parent.getName()) && parent.getName().equals(child.getName()))
ret... | [
"boolean",
"canContain",
"(",
"Tag",
"parent",
",",
"Tag",
"child",
")",
"{",
"Validate",
".",
"notNull",
"(",
"child",
")",
";",
"if",
"(",
"child",
".",
"isBlock",
"(",
")",
"&&",
"!",
"parent",
".",
"canContainBlock",
"(",
")",
")",
"return",
"fal... | Test if this tag, the prospective parent, can accept the proposed child.
@param child potential child tag.
@return true if this can contain child. | [
"Test",
"if",
"this",
"tag",
"the",
"prospective",
"parent",
"can",
"accept",
"the",
"proposed",
"child",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlParser.java#L530-L561 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/routing/DefaultPageBook.java | DefaultPageBook.readAnnotationValue | static String readAnnotationValue(Annotation annotation) {
try {
Method m = annotation.getClass().getMethod("value");
return (String) m.invoke(annotation);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Encountered a configured annotation that " +
... | java | static String readAnnotationValue(Annotation annotation) {
try {
Method m = annotation.getClass().getMethod("value");
return (String) m.invoke(annotation);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Encountered a configured annotation that " +
... | [
"static",
"String",
"readAnnotationValue",
"(",
"Annotation",
"annotation",
")",
"{",
"try",
"{",
"Method",
"m",
"=",
"annotation",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"value\"",
")",
";",
"return",
"(",
"String",
")",
"m",
".",
"invoke",
... | A simple utility method that reads the String value attribute of any annotation
instance. | [
"A",
"simple",
"utility",
"method",
"that",
"reads",
"the",
"String",
"value",
"attribute",
"of",
"any",
"annotation",
"instance",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/routing/DefaultPageBook.java#L913-L929 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/MvelEvaluatorCompiler.java | MvelEvaluatorCompiler.singleBackingTypeParserContext | private ParserContext singleBackingTypeParserContext() throws ExpressionCompileException {
ParserContext context = new ParserContext();
context.setStrongTyping(true);
context.addInput("this", backingType);
PropertyDescriptor[] propertyDescriptors;
try {
propertyDescriptors = Introspector.getB... | java | private ParserContext singleBackingTypeParserContext() throws ExpressionCompileException {
ParserContext context = new ParserContext();
context.setStrongTyping(true);
context.addInput("this", backingType);
PropertyDescriptor[] propertyDescriptors;
try {
propertyDescriptors = Introspector.getB... | [
"private",
"ParserContext",
"singleBackingTypeParserContext",
"(",
")",
"throws",
"ExpressionCompileException",
"{",
"ParserContext",
"context",
"=",
"new",
"ParserContext",
"(",
")",
";",
"context",
".",
"setStrongTyping",
"(",
"true",
")",
";",
"context",
".",
"ad... | generates a parsing context with type information from the backing type's javabean properties | [
"generates",
"a",
"parsing",
"context",
"with",
"type",
"information",
"from",
"the",
"backing",
"type",
"s",
"javabean",
"properties"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/MvelEvaluatorCompiler.java#L162-L220 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/routing/PathMatcherChain.java | PathMatcherChain.toMatchChain | private static List<PathMatcher> toMatchChain(String path) {
String[] pieces = path.split(PATH_SEPARATOR);
List<PathMatcher> matchers = new ArrayList<PathMatcher>();
for (String piece : pieces) {
matchers.add((piece.startsWith(":")) ? new GreedyPathMatcher(piece) : new SimplePathMat... | java | private static List<PathMatcher> toMatchChain(String path) {
String[] pieces = path.split(PATH_SEPARATOR);
List<PathMatcher> matchers = new ArrayList<PathMatcher>();
for (String piece : pieces) {
matchers.add((piece.startsWith(":")) ? new GreedyPathMatcher(piece) : new SimplePathMat... | [
"private",
"static",
"List",
"<",
"PathMatcher",
">",
"toMatchChain",
"(",
"String",
"path",
")",
"{",
"String",
"[",
"]",
"pieces",
"=",
"path",
".",
"split",
"(",
"PATH_SEPARATOR",
")",
";",
"List",
"<",
"PathMatcher",
">",
"matchers",
"=",
"new",
"Arr... | converts a string path to a tree of heterogenous matchers | [
"converts",
"a",
"string",
"path",
"to",
"a",
"tree",
"of",
"heterogenous",
"matchers"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/routing/PathMatcherChain.java#L21-L30 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/NettyImapClient.java | NettyImapClient.connect | @Override
public synchronized boolean connect(final DisconnectListener listener) {
reset();
ChannelFuture future = bootstrap.connect(new InetSocketAddress(config.getHost(),
config.getPort()));
Channel channel = future.awaitUninterruptibly().getChannel();
if (!future.isSuccess()) {
thro... | java | @Override
public synchronized boolean connect(final DisconnectListener listener) {
reset();
ChannelFuture future = bootstrap.connect(new InetSocketAddress(config.getHost(),
config.getPort()));
Channel channel = future.awaitUninterruptibly().getChannel();
if (!future.isSuccess()) {
thro... | [
"@",
"Override",
"public",
"synchronized",
"boolean",
"connect",
"(",
"final",
"DisconnectListener",
"listener",
")",
"{",
"reset",
"(",
")",
";",
"ChannelFuture",
"future",
"=",
"bootstrap",
".",
"connect",
"(",
"new",
"InetSocketAddress",
"(",
"config",
".",
... | Connects to the IMAP server logs in with the given credentials. | [
"Connects",
"to",
"the",
"IMAP",
"server",
"logs",
"in",
"with",
"the",
"given",
"credentials",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/NettyImapClient.java#L118-L144 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/NettyImapClient.java | NettyImapClient.disconnect | @Override
public synchronized void disconnect() {
try {
// If there is an error with the handler, dont bother logging out.
if (!mailClientHandler.isHalted()) {
if (mailClientHandler.idleRequested.get()) {
log.warn("Disconnect called while IDLE, leaving idle and logging out.");
... | java | @Override
public synchronized void disconnect() {
try {
// If there is an error with the handler, dont bother logging out.
if (!mailClientHandler.isHalted()) {
if (mailClientHandler.idleRequested.get()) {
log.warn("Disconnect called while IDLE, leaving idle and logging out.");
... | [
"@",
"Override",
"public",
"synchronized",
"void",
"disconnect",
"(",
")",
"{",
"try",
"{",
"// If there is an error with the handler, dont bother logging out.",
"if",
"(",
"!",
"mailClientHandler",
".",
"isHalted",
"(",
")",
")",
"{",
"if",
"(",
"mailClientHandler",
... | Logs out of the current IMAP session and releases all resources, including
executor services. | [
"Logs",
"out",
"of",
"the",
"current",
"IMAP",
"session",
"and",
"releases",
"all",
"resources",
"including",
"executor",
"services",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/NettyImapClient.java#L221-L253 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/Parsing.java | Parsing.tokenize | public static List<Token> tokenize(String warpRawText, EvaluatorCompiler compiler) throws ExpressionCompileException {
ArrayList<Token> tokens = new ArrayList<Token>();
//simple state machine to iterate the text and break it up into chunks
char[] characters = warpRawText.toCharArray();
StringBui... | java | public static List<Token> tokenize(String warpRawText, EvaluatorCompiler compiler) throws ExpressionCompileException {
ArrayList<Token> tokens = new ArrayList<Token>();
//simple state machine to iterate the text and break it up into chunks
char[] characters = warpRawText.toCharArray();
StringBui... | [
"public",
"static",
"List",
"<",
"Token",
">",
"tokenize",
"(",
"String",
"warpRawText",
",",
"EvaluatorCompiler",
"compiler",
")",
"throws",
"ExpressionCompileException",
"{",
"ArrayList",
"<",
"Token",
">",
"tokens",
"=",
"new",
"ArrayList",
"<",
"Token",
">",... | tokenizes text into raw text chunks interspersed with expression chunks | [
"tokenizes",
"text",
"into",
"raw",
"text",
"chunks",
"interspersed",
"with",
"expression",
"chunks"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/Parsing.java#L97-L152 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/ScanAndCompileBootstrapper.java | ScanAndCompileBootstrapper.collectBindings | private void collectBindings(List<SitebricksModule.LinkingBinder> bindings,
Set<PageBook.Page> pagesToCompile) {
// Reverse the method map for easy lookup of HTTP method annotations.
Map<Class<? extends Annotation>, String> methodSet = null;
//go thru bindings and obtain pag... | java | private void collectBindings(List<SitebricksModule.LinkingBinder> bindings,
Set<PageBook.Page> pagesToCompile) {
// Reverse the method map for easy lookup of HTTP method annotations.
Map<Class<? extends Annotation>, String> methodSet = null;
//go thru bindings and obtain pag... | [
"private",
"void",
"collectBindings",
"(",
"List",
"<",
"SitebricksModule",
".",
"LinkingBinder",
">",
"bindings",
",",
"Set",
"<",
"PageBook",
".",
"Page",
">",
"pagesToCompile",
")",
"{",
"// Reverse the method map for easy lookup of HTTP method annotations.",
"Map",
... | processes all explicit bindings, including static resources. | [
"processes",
"all",
"explicit",
"bindings",
"including",
"static",
"resources",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/ScanAndCompileBootstrapper.java#L129-L162 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/ScanAndCompileBootstrapper.java | ScanAndCompileBootstrapper.scanPagesToCompile | private Set<PageBook.Page> scanPagesToCompile(Set<Class<?>> set) {
Set<Templates.Descriptor> templates = Sets.newHashSet();
Set<PageBook.Page> pagesToCompile = Sets.newHashSet();
for (Class<?> pageClass : set) {
EmbedAs embedAs = pageClass.getAnnotation(EmbedAs.class);
if (null != embedAs) {
... | java | private Set<PageBook.Page> scanPagesToCompile(Set<Class<?>> set) {
Set<Templates.Descriptor> templates = Sets.newHashSet();
Set<PageBook.Page> pagesToCompile = Sets.newHashSet();
for (Class<?> pageClass : set) {
EmbedAs embedAs = pageClass.getAnnotation(EmbedAs.class);
if (null != embedAs) {
... | [
"private",
"Set",
"<",
"PageBook",
".",
"Page",
">",
"scanPagesToCompile",
"(",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"set",
")",
"{",
"Set",
"<",
"Templates",
".",
"Descriptor",
">",
"templates",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"Se... | goes through the set of scanned classes and builds pages out of them. | [
"goes",
"through",
"the",
"set",
"of",
"scanned",
"classes",
"and",
"builds",
"pages",
"out",
"of",
"them",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/ScanAndCompileBootstrapper.java#L165-L209 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/rendering/control/DecorateWidget.java | DecorateWidget.nextDecoratedClassInHierarchy | private Class<?> nextDecoratedClassInHierarchy(Class<?> previousTemplateClass,
Class<?> candidate) {
if (candidate == previousTemplateClass) {
// terminate the recursion
return null;
} else if (candidate == Object.class) {
// this should n... | java | private Class<?> nextDecoratedClassInHierarchy(Class<?> previousTemplateClass,
Class<?> candidate) {
if (candidate == previousTemplateClass) {
// terminate the recursion
return null;
} else if (candidate == Object.class) {
// this should n... | [
"private",
"Class",
"<",
"?",
">",
"nextDecoratedClassInHierarchy",
"(",
"Class",
"<",
"?",
">",
"previousTemplateClass",
",",
"Class",
"<",
"?",
">",
"candidate",
")",
"{",
"if",
"(",
"candidate",
"==",
"previousTemplateClass",
")",
"{",
"// terminate the recur... | recursively find the next superclass with an @Decorated annotation | [
"recursively",
"find",
"the",
"next",
"superclass",
"with",
"an"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/rendering/control/DecorateWidget.java#L74-L90 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/imap/Message.java | Message.setBody | @Override public void setBody(String body) {
assert bodyParts.isEmpty() : "Unexpected set body call to a multipart email";
bodyParts.add(new BodyPart(body));
} | java | @Override public void setBody(String body) {
assert bodyParts.isEmpty() : "Unexpected set body call to a multipart email";
bodyParts.add(new BodyPart(body));
} | [
"@",
"Override",
"public",
"void",
"setBody",
"(",
"String",
"body",
")",
"{",
"assert",
"bodyParts",
".",
"isEmpty",
"(",
")",
":",
"\"Unexpected set body call to a multipart email\"",
";",
"bodyParts",
".",
"add",
"(",
"new",
"BodyPart",
"(",
"body",
")",
")... | Short hand. | [
"Short",
"hand",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/imap/Message.java#L58-L61 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/imap/StoreLabelsResponseExtractor.java | StoreLabelsResponseExtractor.extract | @Override
public Set<String> extract(List<String> messages) throws ExtractionException {
boolean gotFetch = false;
Set<String> result = null;
// Find FETCH, throw error if none or more than one, or if we receive an error response.
String fetchStr = null;
for (int i = 0, messagesSize = messages.si... | java | @Override
public Set<String> extract(List<String> messages) throws ExtractionException {
boolean gotFetch = false;
Set<String> result = null;
// Find FETCH, throw error if none or more than one, or if we receive an error response.
String fetchStr = null;
for (int i = 0, messagesSize = messages.si... | [
"@",
"Override",
"public",
"Set",
"<",
"String",
">",
"extract",
"(",
"List",
"<",
"String",
">",
"messages",
")",
"throws",
"ExtractionException",
"{",
"boolean",
"gotFetch",
"=",
"false",
";",
"Set",
"<",
"String",
">",
"result",
"=",
"null",
";",
"// ... | Parse the response, which includes label settings and command status.
We expect only one FETCH response as we only set labels on one msg.
http://code.google.com/apis/gmail/imap/#x-gm-labels
C: a011 STORE_FLAGS 1 +X-GM-LABELS (foo)
S: * 1 FETCH (X-GM-LABELS (\Inbox \Sent Important "Muy Importante" foo))
S: a011 OK STOR... | [
"Parse",
"the",
"response",
"which",
"includes",
"label",
"settings",
"and",
"command",
"status",
".",
"We",
"expect",
"only",
"one",
"FETCH",
"response",
"as",
"we",
"only",
"set",
"labels",
"on",
"one",
"msg",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/imap/StoreLabelsResponseExtractor.java#L33-L70 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/MailClientHandler.java | MailClientHandler.enqueue | public void enqueue(CommandCompletion completion) {
completions.add(completion);
commandTrace.add(new Date().toString() + " " + completion.toString());
} | java | public void enqueue(CommandCompletion completion) {
completions.add(completion);
commandTrace.add(new Date().toString() + " " + completion.toString());
} | [
"public",
"void",
"enqueue",
"(",
"CommandCompletion",
"completion",
")",
"{",
"completions",
".",
"add",
"(",
"completion",
")",
";",
"commandTrace",
".",
"add",
"(",
"new",
"Date",
"(",
")",
".",
"toString",
"(",
")",
"+",
"\" \"",
"+",
"completion",
"... | DO NOT synchronize! | [
"DO",
"NOT",
"synchronize!"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/MailClientHandler.java#L121-L124 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/MailClientHandler.java | MailClientHandler.complete | private synchronized void complete(String message) {
// This is a weird problem with writing stuff while idling. Need to investigate it more, but
// for now just ignore it.
if (MESSAGE_COULDNT_BE_FETCHED_REGEX.matcher(message).matches()) {
log.warn("Some messages in the batch could not be fetched... | java | private synchronized void complete(String message) {
// This is a weird problem with writing stuff while idling. Need to investigate it more, but
// for now just ignore it.
if (MESSAGE_COULDNT_BE_FETCHED_REGEX.matcher(message).matches()) {
log.warn("Some messages in the batch could not be fetched... | [
"private",
"synchronized",
"void",
"complete",
"(",
"String",
"message",
")",
"{",
"// This is a weird problem with writing stuff while idling. Need to investigate it more, but",
"// for now just ignore it.",
"if",
"(",
"MESSAGE_COULDNT_BE_FETCHED_REGEX",
".",
"matcher",
"(",
"mess... | This is synchronized to ensure that we process the queue serially. | [
"This",
"is",
"synchronized",
"to",
"ensure",
"that",
"we",
"process",
"the",
"queue",
"serially",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/MailClientHandler.java#L263-L304 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/MailClientHandler.java | MailClientHandler.observe | void observe(FolderObserver observer) {
synchronized (idleMutex) {
this.observer = observer;
pushedData = new PushedData();
idleAcknowledged.set(false);
}
} | java | void observe(FolderObserver observer) {
synchronized (idleMutex) {
this.observer = observer;
pushedData = new PushedData();
idleAcknowledged.set(false);
}
} | [
"void",
"observe",
"(",
"FolderObserver",
"observer",
")",
"{",
"synchronized",
"(",
"idleMutex",
")",
"{",
"this",
".",
"observer",
"=",
"observer",
";",
"pushedData",
"=",
"new",
"PushedData",
"(",
")",
";",
"idleAcknowledged",
".",
"set",
"(",
"false",
... | Registers a FolderObserver to receive events happening with a particular
folder. Typically an IMAP IDLE feature. If called multiple times, will
overwrite the currently set observer. | [
"Registers",
"a",
"FolderObserver",
"to",
"receive",
"events",
"happening",
"with",
"a",
"particular",
"folder",
".",
"Typically",
"an",
"IMAP",
"IDLE",
"feature",
".",
"If",
"called",
"multiple",
"times",
"will",
"overwrite",
"the",
"currently",
"set",
"observe... | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/MailClientHandler.java#L343-L349 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/Localizer.java | Localizer.defaultLocalizationFor | public static Localization defaultLocalizationFor(Class<?> iface) {
Map<String, String> defaultMessages = Maps.newHashMap();
for (Method method : iface.getMethods()) {
Message msg = method.getAnnotation(Message.class);
if (null != msg) {
defaultMessages.put(method.getName(), msg.message());... | java | public static Localization defaultLocalizationFor(Class<?> iface) {
Map<String, String> defaultMessages = Maps.newHashMap();
for (Method method : iface.getMethods()) {
Message msg = method.getAnnotation(Message.class);
if (null != msg) {
defaultMessages.put(method.getName(), msg.message());... | [
"public",
"static",
"Localization",
"defaultLocalizationFor",
"(",
"Class",
"<",
"?",
">",
"iface",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"defaultMessages",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
... | Returns a localization value object describing the defaults specified in the @Message
annotations of the methods on the given i18n interface. The locale used is the system
default. | [
"Returns",
"a",
"localization",
"value",
"object",
"describing",
"the",
"defaults",
"specified",
"in",
"the"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/Localizer.java#L256-L267 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/oauth/XoauthSasl.java | XoauthSasl.build | public String build(Protocol protocol, String oauthToken, String oauthTokenSecret)
throws IOException, OAuthException, URISyntaxException {
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.tokenSecret = oauthTokenSecret;
Map<String, String> parameters = new HashMap<String, String>();
... | java | public String build(Protocol protocol, String oauthToken, String oauthTokenSecret)
throws IOException, OAuthException, URISyntaxException {
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.tokenSecret = oauthTokenSecret;
Map<String, String> parameters = new HashMap<String, String>();
... | [
"public",
"String",
"build",
"(",
"Protocol",
"protocol",
",",
"String",
"oauthToken",
",",
"String",
"oauthTokenSecret",
")",
"throws",
"IOException",
",",
"OAuthException",
",",
"URISyntaxException",
"{",
"OAuthAccessor",
"accessor",
"=",
"new",
"OAuthAccessor",
"... | Builds an XOAUTH SASL client response.
@return A base-64 encoded containing the auth string suitable for login via xoauth. | [
"Builds",
"an",
"XOAUTH",
"SASL",
"client",
"response",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/oauth/XoauthSasl.java#L32-L66 | train |
dhanji/sitebricks | sitebricks-converter/src/main/java/com/google/sitebricks/conversion/generics/Generics.java | Generics.erase | public static Class<?> erase(Type type)
{
if (type instanceof Class<?>)
{
return (Class<?>) type;
}
else if (type instanceof ParameterizedType)
{
return (Class<?>) ((ParameterizedType) type).getRawType();
}
else if (type instanceof TypeVariable<?>)
{
TypeVariable<?> tv = (TypeVaria... | java | public static Class<?> erase(Type type)
{
if (type instanceof Class<?>)
{
return (Class<?>) type;
}
else if (type instanceof ParameterizedType)
{
return (Class<?>) ((ParameterizedType) type).getRawType();
}
else if (type instanceof TypeVariable<?>)
{
TypeVariable<?> tv = (TypeVaria... | [
"public",
"static",
"Class",
"<",
"?",
">",
"erase",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"Class",
"<",
"?",
">",
")",
"{",
"return",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"}",
"else",
"if",
"(",
"type",
"ins... | Returns the erasure of the given type. | [
"Returns",
"the",
"erasure",
"of",
"the",
"given",
"type",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-converter/src/main/java/com/google/sitebricks/conversion/generics/Generics.java#L27-L55 | train |
dhanji/sitebricks | sitebricks-converter/src/main/java/com/google/sitebricks/conversion/generics/Generics.java | Generics.mapTypeParameters | private static Type mapTypeParameters(Type toMapType, Type typeAndParams)
{
if (isMissingTypeParameters(typeAndParams))
{
return erase(toMapType);
}
else
{
VarMap varMap = new VarMap();
Type handlingTypeAndParams = typeAndParams;
while (handlingTypeAndParams instanceof ParameterizedType... | java | private static Type mapTypeParameters(Type toMapType, Type typeAndParams)
{
if (isMissingTypeParameters(typeAndParams))
{
return erase(toMapType);
}
else
{
VarMap varMap = new VarMap();
Type handlingTypeAndParams = typeAndParams;
while (handlingTypeAndParams instanceof ParameterizedType... | [
"private",
"static",
"Type",
"mapTypeParameters",
"(",
"Type",
"toMapType",
",",
"Type",
"typeAndParams",
")",
"{",
"if",
"(",
"isMissingTypeParameters",
"(",
"typeAndParams",
")",
")",
"{",
"return",
"erase",
"(",
"toMapType",
")",
";",
"}",
"else",
"{",
"V... | Maps type parameters in a type to their values.
@param toMapType
Type possibly containing type arguments
@param typeAndParams
must be either ParameterizedType, or (in case there are no
type arguments, or it's a raw type) Class
@return toMapType, but with type parameters from typeAndParams replaced. | [
"Maps",
"type",
"parameters",
"in",
"a",
"type",
"to",
"their",
"values",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-converter/src/main/java/com/google/sitebricks/conversion/generics/Generics.java#L67-L88 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java | HtmlTemplateCompiler.walk | @NotNull
private <N extends Node> WidgetChain walk(PageCompilingContext pc, N node) {
WidgetChain widgetChain = Chains.proceeding();
for (Node n: node.childNodes()) {
if (n instanceof Element) {
final Element child = (Element) n;
//push form if this is a ... | java | @NotNull
private <N extends Node> WidgetChain walk(PageCompilingContext pc, N node) {
WidgetChain widgetChain = Chains.proceeding();
for (Node n: node.childNodes()) {
if (n instanceof Element) {
final Element child = (Element) n;
//push form if this is a ... | [
"@",
"NotNull",
"private",
"<",
"N",
"extends",
"Node",
">",
"WidgetChain",
"walk",
"(",
"PageCompilingContext",
"pc",
",",
"N",
"node",
")",
"{",
"WidgetChain",
"widgetChain",
"=",
"Chains",
".",
"proceeding",
"(",
")",
";",
"for",
"(",
"Node",
"n",
":"... | Walks the DOM recursively, and converts elements into corresponding sitebricks widgets. | [
"Walks",
"the",
"DOM",
"recursively",
"and",
"converts",
"elements",
"into",
"corresponding",
"sitebricks",
"widgets",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java#L110-L201 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java | HtmlTemplateCompiler.lexicalClimb | private boolean lexicalClimb(PageCompilingContext pc, Node node) {
if (node.attr(ANNOTATION).length()>1) {
// Setup a new lexical scope (symbol table changes on each scope encountered).
if (REPEAT_WIDGET.equalsIgnoreCase(node.attr(ANNOTATION_KEY))
|| CHOOSE_WIDGET.equals... | java | private boolean lexicalClimb(PageCompilingContext pc, Node node) {
if (node.attr(ANNOTATION).length()>1) {
// Setup a new lexical scope (symbol table changes on each scope encountered).
if (REPEAT_WIDGET.equalsIgnoreCase(node.attr(ANNOTATION_KEY))
|| CHOOSE_WIDGET.equals... | [
"private",
"boolean",
"lexicalClimb",
"(",
"PageCompilingContext",
"pc",
",",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
".",
"attr",
"(",
"ANNOTATION",
")",
".",
"length",
"(",
")",
">",
"1",
")",
"{",
"// Setup a new lexical scope (symbol table changes on ea... | Called to push a new lexical scope onto the stack. | [
"Called",
"to",
"push",
"a",
"new",
"lexical",
"scope",
"onto",
"the",
"stack",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java#L225-L251 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java | HtmlTemplateCompiler.checkEmbedAgainst | private void checkEmbedAgainst(PageCompilingContext pc, EvaluatorCompiler compiler, Map<String, String> properties, Class<?> embedClass, Node node) {
// TODO also type check them against expressions
for (String property : properties.keySet()) {
try {
if (!compiler.isWritable(property)) {
... | java | private void checkEmbedAgainst(PageCompilingContext pc, EvaluatorCompiler compiler, Map<String, String> properties, Class<?> embedClass, Node node) {
// TODO also type check them against expressions
for (String property : properties.keySet()) {
try {
if (!compiler.isWritable(property)) {
... | [
"private",
"void",
"checkEmbedAgainst",
"(",
"PageCompilingContext",
"pc",
",",
"EvaluatorCompiler",
"compiler",
",",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
",",
"Class",
"<",
"?",
">",
"embedClass",
",",
"Node",
"node",
")",
"{",
"// TODO als... | Ensures that embed bound properties are writable | [
"Ensures",
"that",
"embed",
"bound",
"properties",
"are",
"writable"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java#L520-L543 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java | HtmlTemplateCompiler.findSiblings | public List<Node> findSiblings(Node node) {
Preconditions.checkNotNull(node);
Node parent = node.parent();
if (null == parent) return null;
return parent.childNodes();
} | java | public List<Node> findSiblings(Node node) {
Preconditions.checkNotNull(node);
Node parent = node.parent();
if (null == parent) return null;
return parent.childNodes();
} | [
"public",
"List",
"<",
"Node",
">",
"findSiblings",
"(",
"Node",
"node",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"node",
")",
";",
"Node",
"parent",
"=",
"node",
".",
"parent",
"(",
")",
";",
"if",
"(",
"null",
"==",
"parent",
")",
"retu... | TESTING jsoup.nodes.Node | [
"TESTING",
"jsoup",
".",
"nodes",
".",
"Node"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java#L559-L566 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java | HtmlTemplateCompiler.cleanHtml | private static String cleanHtml(final Node node) {
if (node instanceof Element) {
Element element = ((Element) node);
StringBuilder accum = new StringBuilder();
accum.append("<").append(element.tagName());
for (Attribute attribute: element.attributes()) {
... | java | private static String cleanHtml(final Node node) {
if (node instanceof Element) {
Element element = ((Element) node);
StringBuilder accum = new StringBuilder();
accum.append("<").append(element.tagName());
for (Attribute attribute: element.attributes()) {
... | [
"private",
"static",
"String",
"cleanHtml",
"(",
"final",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
"instanceof",
"Element",
")",
"{",
"Element",
"element",
"=",
"(",
"(",
"Element",
")",
"node",
")",
";",
"StringBuilder",
"accum",
"=",
"new",
"String... | outerHtml from jsoup.Node, Element with suppressed _attribs | [
"outerHtml",
"from",
"jsoup",
".",
"Node",
"Element",
"with",
"suppressed",
"_attribs"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/HtmlTemplateCompiler.java#L586-L636 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/binding/MvelRequestBinder.java | MvelRequestBinder.search | private Object search(Collection<?> collection, String hashKey) {
int hash = Integer.valueOf(hashKey);
for (Object o : collection) {
if (o.hashCode() == hash)
return o;
}
//nothing found
return null;
} | java | private Object search(Collection<?> collection, String hashKey) {
int hash = Integer.valueOf(hashKey);
for (Object o : collection) {
if (o.hashCode() == hash)
return o;
}
//nothing found
return null;
} | [
"private",
"Object",
"search",
"(",
"Collection",
"<",
"?",
">",
"collection",
",",
"String",
"hashKey",
")",
"{",
"int",
"hash",
"=",
"Integer",
".",
"valueOf",
"(",
"hashKey",
")",
";",
"for",
"(",
"Object",
"o",
":",
"collection",
")",
"{",
"if",
... | Linear collection search by hashcode | [
"Linear",
"collection",
"search",
"by",
"hashcode"
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/binding/MvelRequestBinder.java#L104-L114 | train |
dhanji/sitebricks | sitebricks/src/main/java/com/google/sitebricks/compiler/AnnotationNode.java | AnnotationNode.annotation | public AnnotationNode annotation(String annotation) {
this.attr(ANNOTATION, annotation);
String[] kc = AnnotationParser.extractKeyAndContent(annotation);
this.attr(ANNOTATION_KEY, kc[0]);
this.attr(ANNOTATION_CONTENT, kc[1]);
return this;
} | java | public AnnotationNode annotation(String annotation) {
this.attr(ANNOTATION, annotation);
String[] kc = AnnotationParser.extractKeyAndContent(annotation);
this.attr(ANNOTATION_KEY, kc[0]);
this.attr(ANNOTATION_CONTENT, kc[1]);
return this;
} | [
"public",
"AnnotationNode",
"annotation",
"(",
"String",
"annotation",
")",
"{",
"this",
".",
"attr",
"(",
"ANNOTATION",
",",
"annotation",
")",
";",
"String",
"[",
"]",
"kc",
"=",
"AnnotationParser",
".",
"extractKeyAndContent",
"(",
"annotation",
")",
";",
... | Set the annotation of this node.
@param annotation raw annotation
@return this, for chaining | [
"Set",
"the",
"annotation",
"of",
"this",
"node",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks/src/main/java/com/google/sitebricks/compiler/AnnotationNode.java#L42-L48 | train |
dhanji/sitebricks | sitebricks-mail/src/main/java/com/google/sitebricks/mail/imap/StoreFlagsResponseExtractor.java | StoreFlagsResponseExtractor.extract | @Override
public Set<Flag> extract(List<String> messages) throws ExtractionException {
boolean gotFetch = false;
Set<Flag> result = null;
// Find FETCH, throw error if none or more than one, or if we receive an error response.
String fetchStr = null;
for (int i = 0, messagesSize = messages.size()... | java | @Override
public Set<Flag> extract(List<String> messages) throws ExtractionException {
boolean gotFetch = false;
Set<Flag> result = null;
// Find FETCH, throw error if none or more than one, or if we receive an error response.
String fetchStr = null;
for (int i = 0, messagesSize = messages.size()... | [
"@",
"Override",
"public",
"Set",
"<",
"Flag",
">",
"extract",
"(",
"List",
"<",
"String",
">",
"messages",
")",
"throws",
"ExtractionException",
"{",
"boolean",
"gotFetch",
"=",
"false",
";",
"Set",
"<",
"Flag",
">",
"result",
"=",
"null",
";",
"// Find... | Parse the response, which includes new flag settings and command status.
We expect only one FETCH response as we only set flags on one msg.
http://tools.ietf.org/html/rfc3501#section-6.4.6
C: A003 STORE_FLAGS 6 +FLAGS (\Deleted)
S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen) UID 6)
S: A003 OK STORE_FLAGS completed | [
"Parse",
"the",
"response",
"which",
"includes",
"new",
"flag",
"settings",
"and",
"command",
"status",
".",
"We",
"expect",
"only",
"one",
"FETCH",
"response",
"as",
"we",
"only",
"set",
"flags",
"on",
"one",
"msg",
"."
] | 8682029a78bd48fb8566173d970800499e9e5d97 | https://github.com/dhanji/sitebricks/blob/8682029a78bd48fb8566173d970800499e9e5d97/sitebricks-mail/src/main/java/com/google/sitebricks/mail/imap/StoreFlagsResponseExtractor.java#L28-L61 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.getArticleTitle | protected Element getArticleTitle() {
Element articleTitle = mDocument.createElement("h1");
articleTitle.html(mDocument.title());
return articleTitle;
} | java | protected Element getArticleTitle() {
Element articleTitle = mDocument.createElement("h1");
articleTitle.html(mDocument.title());
return articleTitle;
} | [
"protected",
"Element",
"getArticleTitle",
"(",
")",
"{",
"Element",
"articleTitle",
"=",
"mDocument",
".",
"createElement",
"(",
"\"h1\"",
")",
";",
"articleTitle",
".",
"html",
"(",
"mDocument",
".",
"title",
"(",
")",
")",
";",
"return",
"articleTitle",
"... | Get the article title as an H1. Currently just uses document.title, we
might want to be smarter in the future.
@return | [
"Get",
"the",
"article",
"title",
"as",
"an",
"H1",
".",
"Currently",
"just",
"uses",
"document",
".",
"title",
"we",
"might",
"want",
"to",
"be",
"smarter",
"in",
"the",
"future",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L134-L138 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.prepDocument | protected void prepDocument() {
/**
* In some cases a body element can't be found (if the HTML is totally
* hosed for example) so we create a new body node and append it to the
* document.
*/
if (mDocument.body() == null) {
mDocument.appendElement("body");... | java | protected void prepDocument() {
/**
* In some cases a body element can't be found (if the HTML is totally
* hosed for example) so we create a new body node and append it to the
* document.
*/
if (mDocument.body() == null) {
mDocument.appendElement("body");... | [
"protected",
"void",
"prepDocument",
"(",
")",
"{",
"/**\n * In some cases a body element can't be found (if the HTML is totally\n * hosed for example) so we create a new body node and append it to the\n * document.\n */",
"if",
"(",
"mDocument",
".",
"body",
... | Prepare the HTML document for readability to scrape it. This includes
things like stripping javascript, CSS, and handling terrible markup. | [
"Prepare",
"the",
"HTML",
"document",
"for",
"readability",
"to",
"scrape",
"it",
".",
"This",
"includes",
"things",
"like",
"stripping",
"javascript",
"CSS",
"and",
"handling",
"terrible",
"markup",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L144-L183 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.prepArticle | private void prepArticle(Element articleContent) {
cleanStyles(articleContent);
killBreaks(articleContent);
/* Clean out junk from the article content */
clean(articleContent, "form");
clean(articleContent, "object");
clean(articleContent, "h1");
/**
* I... | java | private void prepArticle(Element articleContent) {
cleanStyles(articleContent);
killBreaks(articleContent);
/* Clean out junk from the article content */
clean(articleContent, "form");
clean(articleContent, "object");
clean(articleContent, "h1");
/**
* I... | [
"private",
"void",
"prepArticle",
"(",
"Element",
"articleContent",
")",
"{",
"cleanStyles",
"(",
"articleContent",
")",
";",
"killBreaks",
"(",
"articleContent",
")",
";",
"/* Clean out junk from the article content */",
"clean",
"(",
"articleContent",
",",
"\"form\"",... | Prepare the article node for display. Clean out any inline styles,
iframes, forms, strip extraneous <p> tags, etc.
@param articleContent | [
"Prepare",
"the",
"article",
"node",
"for",
"display",
".",
"Clean",
"out",
"any",
"inline",
"styles",
"iframes",
"forms",
"strip",
"extraneous",
"<",
";",
"p>",
";",
"tags",
"etc",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L191-L239 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.getInnerText | private static String getInnerText(Element e, boolean normalizeSpaces) {
String textContent = e.text().trim();
if (normalizeSpaces) {
textContent = textContent.replaceAll(Patterns.REGEX_NORMALIZE, "");
}
return textContent;
} | java | private static String getInnerText(Element e, boolean normalizeSpaces) {
String textContent = e.text().trim();
if (normalizeSpaces) {
textContent = textContent.replaceAll(Patterns.REGEX_NORMALIZE, "");
}
return textContent;
} | [
"private",
"static",
"String",
"getInnerText",
"(",
"Element",
"e",
",",
"boolean",
"normalizeSpaces",
")",
"{",
"String",
"textContent",
"=",
"e",
".",
"text",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"normalizeSpaces",
")",
"{",
"textContent",
... | Get the inner text of a node - cross browser compatibly. This also strips
out any excess whitespace to be found.
@param e
@param normalizeSpaces
@return | [
"Get",
"the",
"inner",
"text",
"of",
"a",
"node",
"-",
"cross",
"browser",
"compatibly",
".",
"This",
"also",
"strips",
"out",
"any",
"excess",
"whitespace",
"to",
"be",
"found",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L494-L502 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.getCharCount | private static int getCharCount(Element e, String s) {
if (s == null || s.length() == 0) {
s = ",";
}
return getInnerText(e, true).split(s).length;
} | java | private static int getCharCount(Element e, String s) {
if (s == null || s.length() == 0) {
s = ",";
}
return getInnerText(e, true).split(s).length;
} | [
"private",
"static",
"int",
"getCharCount",
"(",
"Element",
"e",
",",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"s",
"=",
"\",\"",
";",
"}",
"return",
"getInnerText",
"(",
"e",... | Get the number of times a string s appears in the node e.
@param e
@param s
@return | [
"Get",
"the",
"number",
"of",
"times",
"a",
"string",
"s",
"appears",
"in",
"the",
"node",
"e",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L511-L516 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.cleanStyles | private static void cleanStyles(Element e) {
if (e == null) {
return;
}
Element cur = e.children().first();
// Remove any root styles, if we're able.
if (!"readability-styled".equals(e.className())) {
e.removeAttr("style");
}
// Go until... | java | private static void cleanStyles(Element e) {
if (e == null) {
return;
}
Element cur = e.children().first();
// Remove any root styles, if we're able.
if (!"readability-styled".equals(e.className())) {
e.removeAttr("style");
}
// Go until... | [
"private",
"static",
"void",
"cleanStyles",
"(",
"Element",
"e",
")",
"{",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Element",
"cur",
"=",
"e",
".",
"children",
"(",
")",
".",
"first",
"(",
")",
";",
"// Remove any root styles, if we... | Remove the style attribute on every e and under.
@param e | [
"Remove",
"the",
"style",
"attribute",
"on",
"every",
"e",
"and",
"under",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L523-L544 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.getLinkDensity | private static float getLinkDensity(Element e) {
Elements links = getElementsByTag(e, "a");
int textLength = getInnerText(e, true).length();
float linkLength = 0.0F;
for (Element link : links) {
linkLength += getInnerText(link, true).length();
}
return linkLen... | java | private static float getLinkDensity(Element e) {
Elements links = getElementsByTag(e, "a");
int textLength = getInnerText(e, true).length();
float linkLength = 0.0F;
for (Element link : links) {
linkLength += getInnerText(link, true).length();
}
return linkLen... | [
"private",
"static",
"float",
"getLinkDensity",
"(",
"Element",
"e",
")",
"{",
"Elements",
"links",
"=",
"getElementsByTag",
"(",
"e",
",",
"\"a\"",
")",
";",
"int",
"textLength",
"=",
"getInnerText",
"(",
"e",
",",
"true",
")",
".",
"length",
"(",
")",
... | Get the density of links as a percentage of the content. This is the
amount of text that is inside a link divided by the total text in the
node.
@param e
@return | [
"Get",
"the",
"density",
"of",
"links",
"as",
"a",
"percentage",
"of",
"the",
"content",
".",
"This",
"is",
"the",
"amount",
"of",
"text",
"that",
"is",
"inside",
"a",
"link",
"divided",
"by",
"the",
"total",
"text",
"in",
"the",
"node",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L554-L562 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.killBreaks | private static void killBreaks(Element e) {
e.html(e.html().replaceAll(Patterns.REGEX_KILL_BREAKS, "<br />"));
} | java | private static void killBreaks(Element e) {
e.html(e.html().replaceAll(Patterns.REGEX_KILL_BREAKS, "<br />"));
} | [
"private",
"static",
"void",
"killBreaks",
"(",
"Element",
"e",
")",
"{",
"e",
".",
"html",
"(",
"e",
".",
"html",
"(",
")",
".",
"replaceAll",
"(",
"Patterns",
".",
"REGEX_KILL_BREAKS",
",",
"\"<br />\"",
")",
")",
";",
"}"
] | Remove extraneous break tags from a node.
@param e | [
"Remove",
"extraneous",
"break",
"tags",
"from",
"a",
"node",
"."
] | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L612-L614 | train |
wuman/JReadability | src/main/java/com/wuman/jreadability/Readability.java | Readability.cleanConditionally | private void cleanConditionally(Element e, String tag) {
Elements tagsList = getElementsByTag(e, tag);
/**
* Gather counts for other typical elements embedded within. Traverse
* backwards so we can remove nodes at the same time without effecting
* the traversal.
*
... | java | private void cleanConditionally(Element e, String tag) {
Elements tagsList = getElementsByTag(e, tag);
/**
* Gather counts for other typical elements embedded within. Traverse
* backwards so we can remove nodes at the same time without effecting
* the traversal.
*
... | [
"private",
"void",
"cleanConditionally",
"(",
"Element",
"e",
",",
"String",
"tag",
")",
"{",
"Elements",
"tagsList",
"=",
"getElementsByTag",
"(",
"e",
",",
"tag",
")",
";",
"/**\n * Gather counts for other typical elements embedded within. Traverse\n * bac... | Clean an element of all tags of type "tag" if they look fishy. "Fishy" is
an algorithm based on content length, classnames, link density, number of
images & embeds, etc.
@param e
@param tag | [
"Clean",
"an",
"element",
"of",
"all",
"tags",
"of",
"type",
"tag",
"if",
"they",
"look",
"fishy",
".",
"Fishy",
"is",
"an",
"algorithm",
"based",
"on",
"content",
"length",
"classnames",
"link",
"density",
"number",
"of",
"images",
"&",
"embeds",
"etc",
... | 16c18c42402bd13c6e024c2fd3a86dd28ba53e74 | https://github.com/wuman/JReadability/blob/16c18c42402bd13c6e024c2fd3a86dd28ba53e74/src/main/java/com/wuman/jreadability/Readability.java#L647-L712 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.