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
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
ow2-chameleon/fuchsia
importers/zwave/src/main/java/org/ow2/chameleon/fuchsia/importer/zwave/internal/commandclass/ZWaveAlarmSensorCommandClass.java
ZWaveAlarmSensorCommandClass.initialize
public Collection<SerialMessage> initialize() { ArrayList<SerialMessage> result = new ArrayList<SerialMessage>(); if (this.getNode().getManufacturer() == 0x010F && this.getNode().getDeviceType() == 0x0501) { logger.warn("Detected Fibaro FGBS001 Universal Sensor - this device fails to respond to SENSOR_ALARM_GET and SENSOR_ALARM_SUPPORTED_GET."); return result; } result.add(this.getSupportedMessage()); return result; }
java
public Collection<SerialMessage> initialize() { ArrayList<SerialMessage> result = new ArrayList<SerialMessage>(); if (this.getNode().getManufacturer() == 0x010F && this.getNode().getDeviceType() == 0x0501) { logger.warn("Detected Fibaro FGBS001 Universal Sensor - this device fails to respond to SENSOR_ALARM_GET and SENSOR_ALARM_SUPPORTED_GET."); return result; } result.add(this.getSupportedMessage()); return result; }
[ "public", "Collection", "<", "SerialMessage", ">", "initialize", "(", ")", "{", "ArrayList", "<", "SerialMessage", ">", "result", "=", "new", "ArrayList", "<", "SerialMessage", ">", "(", ")", ";", "if", "(", "this", ".", "getNode", "(", ")", ".", "getManufacturer", "(", ")", "==", "0x010F", "&&", "this", ".", "getNode", "(", ")", ".", "getDeviceType", "(", ")", "==", "0x0501", ")", "{", "logger", ".", "warn", "(", "\"Detected Fibaro FGBS001 Universal Sensor - this device fails to respond to SENSOR_ALARM_GET and SENSOR_ALARM_SUPPORTED_GET.\"", ")", ";", "return", "result", ";", "}", "result", ".", "add", "(", "this", ".", "getSupportedMessage", "(", ")", ")", ";", "return", "result", ";", "}" ]
Initializes the alarm sensor command class. Requests the supported alarm types.
[ "Initializes", "the", "alarm", "sensor", "command", "class", ".", "Requests", "the", "supported", "alarm", "types", "." ]
4e9318eadbdeb945e529789f573b45386e619bed
https://github.com/ow2-chameleon/fuchsia/blob/4e9318eadbdeb945e529789f573b45386e619bed/importers/zwave/src/main/java/org/ow2/chameleon/fuchsia/importer/zwave/internal/commandclass/ZWaveAlarmSensorCommandClass.java#L258-L268
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.newDateTime
public static java.util.Date newDateTime() { return new java.util.Date((System.currentTimeMillis() / SECOND_MILLIS) * SECOND_MILLIS); }
java
public static java.util.Date newDateTime() { return new java.util.Date((System.currentTimeMillis() / SECOND_MILLIS) * SECOND_MILLIS); }
[ "public", "static", "java", ".", "util", ".", "Date", "newDateTime", "(", ")", "{", "return", "new", "java", ".", "util", ".", "Date", "(", "(", "System", ".", "currentTimeMillis", "(", ")", "/", "SECOND_MILLIS", ")", "*", "SECOND_MILLIS", ")", ";", "}" ]
Create a new DateTime. To the last second. This will not create any extra-millis-seconds, which may cause bugs when writing to stores such as databases that round milli-seconds up and down.
[ "Create", "a", "new", "DateTime", ".", "To", "the", "last", "second", ".", "This", "will", "not", "create", "any", "extra", "-", "millis", "-", "seconds", "which", "may", "cause", "bugs", "when", "writing", "to", "stores", "such", "as", "databases", "that", "round", "milli", "-", "seconds", "up", "and", "down", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L65-L67
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.newDate
public static java.sql.Date newDate() { return new java.sql.Date((System.currentTimeMillis() / DAY_MILLIS) * DAY_MILLIS); }
java
public static java.sql.Date newDate() { return new java.sql.Date((System.currentTimeMillis() / DAY_MILLIS) * DAY_MILLIS); }
[ "public", "static", "java", ".", "sql", ".", "Date", "newDate", "(", ")", "{", "return", "new", "java", ".", "sql", ".", "Date", "(", "(", "System", ".", "currentTimeMillis", "(", ")", "/", "DAY_MILLIS", ")", "*", "DAY_MILLIS", ")", ";", "}" ]
Create a new Date. To the last day.
[ "Create", "a", "new", "Date", ".", "To", "the", "last", "day", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L72-L74
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.newTime
public static java.sql.Time newTime() { return new java.sql.Time(System.currentTimeMillis() % DAY_MILLIS); }
java
public static java.sql.Time newTime() { return new java.sql.Time(System.currentTimeMillis() % DAY_MILLIS); }
[ "public", "static", "java", ".", "sql", ".", "Time", "newTime", "(", ")", "{", "return", "new", "java", ".", "sql", ".", "Time", "(", "System", ".", "currentTimeMillis", "(", ")", "%", "DAY_MILLIS", ")", ";", "}" ]
Create a new Time, with no date component.
[ "Create", "a", "new", "Time", "with", "no", "date", "component", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L79-L81
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.secondsDiff
public static int secondsDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / SECOND_MILLIS) - (earlierDate.getTime() / SECOND_MILLIS)); }
java
public static int secondsDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / SECOND_MILLIS) - (earlierDate.getTime() / SECOND_MILLIS)); }
[ "public", "static", "int", "secondsDiff", "(", "Date", "earlierDate", ",", "Date", "laterDate", ")", "{", "if", "(", "earlierDate", "==", "null", "||", "laterDate", "==", "null", ")", "{", "return", "0", ";", "}", "return", "(", "int", ")", "(", "(", "laterDate", ".", "getTime", "(", ")", "/", "SECOND_MILLIS", ")", "-", "(", "earlierDate", ".", "getTime", "(", ")", "/", "SECOND_MILLIS", ")", ")", ";", "}" ]
Get the seconds difference
[ "Get", "the", "seconds", "difference" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L93-L99
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.minutesDiff
public static int minutesDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / MINUTE_MILLIS) - (earlierDate.getTime() / MINUTE_MILLIS)); }
java
public static int minutesDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / MINUTE_MILLIS) - (earlierDate.getTime() / MINUTE_MILLIS)); }
[ "public", "static", "int", "minutesDiff", "(", "Date", "earlierDate", ",", "Date", "laterDate", ")", "{", "if", "(", "earlierDate", "==", "null", "||", "laterDate", "==", "null", ")", "{", "return", "0", ";", "}", "return", "(", "int", ")", "(", "(", "laterDate", ".", "getTime", "(", ")", "/", "MINUTE_MILLIS", ")", "-", "(", "earlierDate", ".", "getTime", "(", ")", "/", "MINUTE_MILLIS", ")", ")", ";", "}" ]
Get the minutes difference
[ "Get", "the", "minutes", "difference" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L104-L110
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.hoursDiff
public static int hoursDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / HOUR_MILLIS) - (earlierDate.getTime() / HOUR_MILLIS)); }
java
public static int hoursDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / HOUR_MILLIS) - (earlierDate.getTime() / HOUR_MILLIS)); }
[ "public", "static", "int", "hoursDiff", "(", "Date", "earlierDate", ",", "Date", "laterDate", ")", "{", "if", "(", "earlierDate", "==", "null", "||", "laterDate", "==", "null", ")", "{", "return", "0", ";", "}", "return", "(", "int", ")", "(", "(", "laterDate", ".", "getTime", "(", ")", "/", "HOUR_MILLIS", ")", "-", "(", "earlierDate", ".", "getTime", "(", ")", "/", "HOUR_MILLIS", ")", ")", ";", "}" ]
Get the hours difference
[ "Get", "the", "hours", "difference" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L115-L121
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.daysDiff
public static int daysDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / DAY_MILLIS) - (earlierDate.getTime() / DAY_MILLIS)); }
java
public static int daysDiff(Date earlierDate, Date laterDate) { if (earlierDate == null || laterDate == null) { return 0; } return (int) ((laterDate.getTime() / DAY_MILLIS) - (earlierDate.getTime() / DAY_MILLIS)); }
[ "public", "static", "int", "daysDiff", "(", "Date", "earlierDate", ",", "Date", "laterDate", ")", "{", "if", "(", "earlierDate", "==", "null", "||", "laterDate", "==", "null", ")", "{", "return", "0", ";", "}", "return", "(", "int", ")", "(", "(", "laterDate", ".", "getTime", "(", ")", "/", "DAY_MILLIS", ")", "-", "(", "earlierDate", ".", "getTime", "(", ")", "/", "DAY_MILLIS", ")", ")", ";", "}" ]
Get the days difference
[ "Get", "the", "days", "difference" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L126-L132
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.rollTime
public static java.sql.Time rollTime(java.util.Date startDate, int period, int amount) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(startDate); gc.add(period, amount); return new java.sql.Time(gc.getTime().getTime()); }
java
public static java.sql.Time rollTime(java.util.Date startDate, int period, int amount) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(startDate); gc.add(period, amount); return new java.sql.Time(gc.getTime().getTime()); }
[ "public", "static", "java", ".", "sql", ".", "Time", "rollTime", "(", "java", ".", "util", ".", "Date", "startDate", ",", "int", "period", ",", "int", "amount", ")", "{", "GregorianCalendar", "gc", "=", "new", "GregorianCalendar", "(", ")", ";", "gc", ".", "setTime", "(", "startDate", ")", ";", "gc", ".", "add", "(", "period", ",", "amount", ")", ";", "return", "new", "java", ".", "sql", ".", "Time", "(", "gc", ".", "getTime", "(", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Roll the java.util.Time forward or backward. @param startDate - The start date @param period Calendar.YEAR etc @param amount - Negative to rollbackwards.
[ "Roll", "the", "java", ".", "util", ".", "Time", "forward", "or", "backward", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L141-L146
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.rollDateTime
public static java.util.Date rollDateTime(java.util.Date startDate, int period, int amount) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(startDate); gc.add(period, amount); return new java.util.Date(gc.getTime().getTime()); }
java
public static java.util.Date rollDateTime(java.util.Date startDate, int period, int amount) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(startDate); gc.add(period, amount); return new java.util.Date(gc.getTime().getTime()); }
[ "public", "static", "java", ".", "util", ".", "Date", "rollDateTime", "(", "java", ".", "util", ".", "Date", "startDate", ",", "int", "period", ",", "int", "amount", ")", "{", "GregorianCalendar", "gc", "=", "new", "GregorianCalendar", "(", ")", ";", "gc", ".", "setTime", "(", "startDate", ")", ";", "gc", ".", "add", "(", "period", ",", "amount", ")", ";", "return", "new", "java", ".", "util", ".", "Date", "(", "gc", ".", "getTime", "(", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Roll the java.util.Date forward or backward. @param startDate - The start date @param period Calendar.YEAR etc @param amount - Negative to rollbackwards.
[ "Roll", "the", "java", ".", "util", ".", "Date", "forward", "or", "backward", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L155-L160
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.rollYears
public static java.sql.Date rollYears(java.util.Date startDate, int years) { return rollDate(startDate, Calendar.YEAR, years); }
java
public static java.sql.Date rollYears(java.util.Date startDate, int years) { return rollDate(startDate, Calendar.YEAR, years); }
[ "public", "static", "java", ".", "sql", ".", "Date", "rollYears", "(", "java", ".", "util", ".", "Date", "startDate", ",", "int", "years", ")", "{", "return", "rollDate", "(", "startDate", ",", "Calendar", ".", "YEAR", ",", "years", ")", ";", "}" ]
Roll the years forward or backward. @param startDate - The start date @param years - Negative to rollbackwards.
[ "Roll", "the", "years", "forward", "or", "backward", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L182-L184
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.dateEquals
@SuppressWarnings("deprecation") public static boolean dateEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) { return false; } return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear(); }
java
@SuppressWarnings("deprecation") public static boolean dateEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) { return false; } return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear(); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "boolean", "dateEquals", "(", "java", ".", "util", ".", "Date", "d1", ",", "java", ".", "util", ".", "Date", "d2", ")", "{", "if", "(", "d1", "==", "null", "||", "d2", "==", "null", ")", "{", "return", "false", ";", "}", "return", "d1", ".", "getDate", "(", ")", "==", "d2", ".", "getDate", "(", ")", "&&", "d1", ".", "getMonth", "(", ")", "==", "d2", ".", "getMonth", "(", ")", "&&", "d1", ".", "getYear", "(", ")", "==", "d2", ".", "getYear", "(", ")", ";", "}" ]
Checks the day, month and year are equal.
[ "Checks", "the", "day", "month", "and", "year", "are", "equal", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L209-L218
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.timeEquals
@SuppressWarnings("deprecation") public static boolean timeEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) { return false; } return d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes() && d1.getSeconds() == d2.getSeconds(); }
java
@SuppressWarnings("deprecation") public static boolean timeEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) { return false; } return d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes() && d1.getSeconds() == d2.getSeconds(); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "boolean", "timeEquals", "(", "java", ".", "util", ".", "Date", "d1", ",", "java", ".", "util", ".", "Date", "d2", ")", "{", "if", "(", "d1", "==", "null", "||", "d2", "==", "null", ")", "{", "return", "false", ";", "}", "return", "d1", ".", "getHours", "(", ")", "==", "d2", ".", "getHours", "(", ")", "&&", "d1", ".", "getMinutes", "(", ")", "==", "d2", ".", "getMinutes", "(", ")", "&&", "d1", ".", "getSeconds", "(", ")", "==", "d2", ".", "getSeconds", "(", ")", ";", "}" ]
Checks the hour, minute and second are equal.
[ "Checks", "the", "hour", "minute", "and", "second", "are", "equal", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L223-L232
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.dateTimeEquals
@SuppressWarnings("deprecation") public static boolean dateTimeEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) { return false; } return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear() && d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes() && d1.getSeconds() == d2.getSeconds(); }
java
@SuppressWarnings("deprecation") public static boolean dateTimeEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) { return false; } return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear() && d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes() && d1.getSeconds() == d2.getSeconds(); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "boolean", "dateTimeEquals", "(", "java", ".", "util", ".", "Date", "d1", ",", "java", ".", "util", ".", "Date", "d2", ")", "{", "if", "(", "d1", "==", "null", "||", "d2", "==", "null", ")", "{", "return", "false", ";", "}", "return", "d1", ".", "getDate", "(", ")", "==", "d2", ".", "getDate", "(", ")", "&&", "d1", ".", "getMonth", "(", ")", "==", "d2", ".", "getMonth", "(", ")", "&&", "d1", ".", "getYear", "(", ")", "==", "d2", ".", "getYear", "(", ")", "&&", "d1", ".", "getHours", "(", ")", "==", "d2", ".", "getHours", "(", ")", "&&", "d1", ".", "getMinutes", "(", ")", "==", "d2", ".", "getMinutes", "(", ")", "&&", "d1", ".", "getSeconds", "(", ")", "==", "d2", ".", "getSeconds", "(", ")", ";", "}" ]
Checks the second, hour, month, day, month and year are equal.
[ "Checks", "the", "second", "hour", "month", "day", "month", "and", "year", "are", "equal", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L237-L249
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.toObject
public static Object toObject(Class<?> clazz, Object value) throws ParseException { if (value == null) { return null; } if (clazz == null) { return value; } if (java.sql.Date.class.isAssignableFrom(clazz)) { return toDate(value); } if (java.sql.Time.class.isAssignableFrom(clazz)) { return toTime(value); } if (java.sql.Timestamp.class.isAssignableFrom(clazz)) { return toTimestamp(value); } if (java.util.Date.class.isAssignableFrom(clazz)) { return toDateTime(value); } return value; }
java
public static Object toObject(Class<?> clazz, Object value) throws ParseException { if (value == null) { return null; } if (clazz == null) { return value; } if (java.sql.Date.class.isAssignableFrom(clazz)) { return toDate(value); } if (java.sql.Time.class.isAssignableFrom(clazz)) { return toTime(value); } if (java.sql.Timestamp.class.isAssignableFrom(clazz)) { return toTimestamp(value); } if (java.util.Date.class.isAssignableFrom(clazz)) { return toDateTime(value); } return value; }
[ "public", "static", "Object", "toObject", "(", "Class", "<", "?", ">", "clazz", ",", "Object", "value", ")", "throws", "ParseException", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "clazz", "==", "null", ")", "{", "return", "value", ";", "}", "if", "(", "java", ".", "sql", ".", "Date", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "toDate", "(", "value", ")", ";", "}", "if", "(", "java", ".", "sql", ".", "Time", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "toTime", "(", "value", ")", ";", "}", "if", "(", "java", ".", "sql", ".", "Timestamp", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "toTimestamp", "(", "value", ")", ";", "}", "if", "(", "java", ".", "util", ".", "Date", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "toDateTime", "(", "value", ")", ";", "}", "return", "value", ";", "}" ]
Convert an Object of type Class to an Object.
[ "Convert", "an", "Object", "of", "type", "Class", "to", "an", "Object", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L254-L276
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.getDateTime
public static java.util.Date getDateTime(Object value) { try { return toDateTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
java
public static java.util.Date getDateTime(Object value) { try { return toDateTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
[ "public", "static", "java", ".", "util", ".", "Date", "getDateTime", "(", "Object", "value", ")", "{", "try", "{", "return", "toDateTime", "(", "value", ")", ";", "}", "catch", "(", "ParseException", "pe", ")", "{", "pe", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Convert an Object to a DateTime, without an Exception
[ "Convert", "an", "Object", "to", "a", "DateTime", "without", "an", "Exception" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L281-L288
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.toDateTime
public static java.util.Date toDateTime(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.util.Date) { return (java.util.Date) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return IN_DATETIME_FORMAT.parse((String) value); } return IN_DATETIME_FORMAT.parse(value.toString()); }
java
public static java.util.Date toDateTime(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.util.Date) { return (java.util.Date) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return IN_DATETIME_FORMAT.parse((String) value); } return IN_DATETIME_FORMAT.parse(value.toString()); }
[ "public", "static", "java", ".", "util", ".", "Date", "toDateTime", "(", "Object", "value", ")", "throws", "ParseException", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "value", "instanceof", "java", ".", "util", ".", "Date", ")", "{", "return", "(", "java", ".", "util", ".", "Date", ")", "value", ";", "}", "if", "(", "value", "instanceof", "String", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "(", "String", ")", "value", ")", ")", "{", "return", "null", ";", "}", "return", "IN_DATETIME_FORMAT", ".", "parse", "(", "(", "String", ")", "value", ")", ";", "}", "return", "IN_DATETIME_FORMAT", ".", "parse", "(", "value", ".", "toString", "(", ")", ")", ";", "}" ]
Convert an Object to a DateTime.
[ "Convert", "an", "Object", "to", "a", "DateTime", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L293-L308
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.getDate
public static java.sql.Date getDate(Object value) { try { return toDate(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
java
public static java.sql.Date getDate(Object value) { try { return toDate(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
[ "public", "static", "java", ".", "sql", ".", "Date", "getDate", "(", "Object", "value", ")", "{", "try", "{", "return", "toDate", "(", "value", ")", ";", "}", "catch", "(", "ParseException", "pe", ")", "{", "pe", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Convert an Object to a Date, without an Exception
[ "Convert", "an", "Object", "to", "a", "Date", "without", "an", "Exception" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L313-L320
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.toDate
public static java.sql.Date toDate(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.sql.Date) { return (java.sql.Date) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return new java.sql.Date(IN_DATE_FORMAT.parse((String) value).getTime()); } return new java.sql.Date(IN_DATE_FORMAT.parse(value.toString()).getTime()); }
java
public static java.sql.Date toDate(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.sql.Date) { return (java.sql.Date) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return new java.sql.Date(IN_DATE_FORMAT.parse((String) value).getTime()); } return new java.sql.Date(IN_DATE_FORMAT.parse(value.toString()).getTime()); }
[ "public", "static", "java", ".", "sql", ".", "Date", "toDate", "(", "Object", "value", ")", "throws", "ParseException", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "value", "instanceof", "java", ".", "sql", ".", "Date", ")", "{", "return", "(", "java", ".", "sql", ".", "Date", ")", "value", ";", "}", "if", "(", "value", "instanceof", "String", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "(", "String", ")", "value", ")", ")", "{", "return", "null", ";", "}", "return", "new", "java", ".", "sql", ".", "Date", "(", "IN_DATE_FORMAT", ".", "parse", "(", "(", "String", ")", "value", ")", ".", "getTime", "(", ")", ")", ";", "}", "return", "new", "java", ".", "sql", ".", "Date", "(", "IN_DATE_FORMAT", ".", "parse", "(", "value", ".", "toString", "(", ")", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Convert an Object to a Date.
[ "Convert", "an", "Object", "to", "a", "Date", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L325-L340
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.getTime
public static java.sql.Time getTime(Object value) { try { return toTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
java
public static java.sql.Time getTime(Object value) { try { return toTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
[ "public", "static", "java", ".", "sql", ".", "Time", "getTime", "(", "Object", "value", ")", "{", "try", "{", "return", "toTime", "(", "value", ")", ";", "}", "catch", "(", "ParseException", "pe", ")", "{", "pe", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Convert an Object to a Time, without an Exception
[ "Convert", "an", "Object", "to", "a", "Time", "without", "an", "Exception" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L345-L352
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.toTime
public static java.sql.Time toTime(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.sql.Time) { return (java.sql.Time) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return new java.sql.Time(IN_TIME_FORMAT.parse((String) value).getTime()); } return new java.sql.Time(IN_TIME_FORMAT.parse(value.toString()).getTime()); }
java
public static java.sql.Time toTime(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.sql.Time) { return (java.sql.Time) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return new java.sql.Time(IN_TIME_FORMAT.parse((String) value).getTime()); } return new java.sql.Time(IN_TIME_FORMAT.parse(value.toString()).getTime()); }
[ "public", "static", "java", ".", "sql", ".", "Time", "toTime", "(", "Object", "value", ")", "throws", "ParseException", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "value", "instanceof", "java", ".", "sql", ".", "Time", ")", "{", "return", "(", "java", ".", "sql", ".", "Time", ")", "value", ";", "}", "if", "(", "value", "instanceof", "String", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "(", "String", ")", "value", ")", ")", "{", "return", "null", ";", "}", "return", "new", "java", ".", "sql", ".", "Time", "(", "IN_TIME_FORMAT", ".", "parse", "(", "(", "String", ")", "value", ")", ".", "getTime", "(", ")", ")", ";", "}", "return", "new", "java", ".", "sql", ".", "Time", "(", "IN_TIME_FORMAT", ".", "parse", "(", "value", ".", "toString", "(", ")", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Convert an Object to a Time.
[ "Convert", "an", "Object", "to", "a", "Time", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L357-L372
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.getTimestamp
public static java.sql.Timestamp getTimestamp(Object value) { try { return toTimestamp(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
java
public static java.sql.Timestamp getTimestamp(Object value) { try { return toTimestamp(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
[ "public", "static", "java", ".", "sql", ".", "Timestamp", "getTimestamp", "(", "Object", "value", ")", "{", "try", "{", "return", "toTimestamp", "(", "value", ")", ";", "}", "catch", "(", "ParseException", "pe", ")", "{", "pe", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Convert an Object to a Timestamp, without an Exception
[ "Convert", "an", "Object", "to", "a", "Timestamp", "without", "an", "Exception" ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L377-L384
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.toTimestamp
public static java.sql.Timestamp toTimestamp(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.sql.Timestamp) { return (java.sql.Timestamp) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return new java.sql.Timestamp(IN_TIMESTAMP_FORMAT.parse((String) value).getTime()); } return new java.sql.Timestamp(IN_TIMESTAMP_FORMAT.parse(value.toString()).getTime()); }
java
public static java.sql.Timestamp toTimestamp(Object value) throws ParseException { if (value == null) { return null; } if (value instanceof java.sql.Timestamp) { return (java.sql.Timestamp) value; } if (value instanceof String) { if ("".equals((String) value)) { return null; } return new java.sql.Timestamp(IN_TIMESTAMP_FORMAT.parse((String) value).getTime()); } return new java.sql.Timestamp(IN_TIMESTAMP_FORMAT.parse(value.toString()).getTime()); }
[ "public", "static", "java", ".", "sql", ".", "Timestamp", "toTimestamp", "(", "Object", "value", ")", "throws", "ParseException", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "value", "instanceof", "java", ".", "sql", ".", "Timestamp", ")", "{", "return", "(", "java", ".", "sql", ".", "Timestamp", ")", "value", ";", "}", "if", "(", "value", "instanceof", "String", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "(", "String", ")", "value", ")", ")", "{", "return", "null", ";", "}", "return", "new", "java", ".", "sql", ".", "Timestamp", "(", "IN_TIMESTAMP_FORMAT", ".", "parse", "(", "(", "String", ")", "value", ")", ".", "getTime", "(", ")", ")", ";", "}", "return", "new", "java", ".", "sql", ".", "Timestamp", "(", "IN_TIMESTAMP_FORMAT", ".", "parse", "(", "value", ".", "toString", "(", ")", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Convert an Object to a Timestamp.
[ "Convert", "an", "Object", "to", "a", "Timestamp", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L389-L405
train
brunocvcunha/inutils4j
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
DateUtils.isTimeInRange
@SuppressWarnings("deprecation") public static boolean isTimeInRange(java.sql.Time start, java.sql.Time end, java.util.Date d) { d = new java.sql.Time(d.getHours(), d.getMinutes(), d.getSeconds()); if (start == null || end == null) { return false; } if (start.before(end) && (!(d.after(start) && d.before(end)))) { return false; } if (end.before(start) && (!(d.after(end) || d.before(start)))) { return false; } return true; }
java
@SuppressWarnings("deprecation") public static boolean isTimeInRange(java.sql.Time start, java.sql.Time end, java.util.Date d) { d = new java.sql.Time(d.getHours(), d.getMinutes(), d.getSeconds()); if (start == null || end == null) { return false; } if (start.before(end) && (!(d.after(start) && d.before(end)))) { return false; } if (end.before(start) && (!(d.after(end) || d.before(start)))) { return false; } return true; }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "boolean", "isTimeInRange", "(", "java", ".", "sql", ".", "Time", "start", ",", "java", ".", "sql", ".", "Time", "end", ",", "java", ".", "util", ".", "Date", "d", ")", "{", "d", "=", "new", "java", ".", "sql", ".", "Time", "(", "d", ".", "getHours", "(", ")", ",", "d", ".", "getMinutes", "(", ")", ",", "d", ".", "getSeconds", "(", ")", ")", ";", "if", "(", "start", "==", "null", "||", "end", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "start", ".", "before", "(", "end", ")", "&&", "(", "!", "(", "d", ".", "after", "(", "start", ")", "&&", "d", ".", "before", "(", "end", ")", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "end", ".", "before", "(", "start", ")", "&&", "(", "!", "(", "d", ".", "after", "(", "end", ")", "||", "d", ".", "before", "(", "start", ")", ")", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Tells you if the date part of a datetime is in a certain time range.
[ "Tells", "you", "if", "the", "date", "part", "of", "a", "datetime", "is", "in", "a", "certain", "time", "range", "." ]
223c4443c2cee662576ce644e552588fa114aa94
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L410-L426
train
thorstenwagner/TraJ
src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java
TrajectoryUtil.combineTrajectory
public static Trajectory combineTrajectory(Trajectory a, Trajectory b){ if(a.getDimension()!=b.getDimension()){ throw new IllegalArgumentException("Combination not possible: The trajectorys does not have the same dimension"); } if(a.size()!=b.size()){ throw new IllegalArgumentException("Combination not possible: The trajectorys does not " + "have the same number of steps a="+a.size() + " b="+b.size()); } Trajectory c = new Trajectory(a.getDimension()); for(int i = 0 ; i < a.size(); i++){ Point3d pos = new Point3d(a.get(i).x+b.get(i).x, a.get(i).y+b.get(i).y, a.get(i).z+b.get(i).z); c.add(pos); } return c; }
java
public static Trajectory combineTrajectory(Trajectory a, Trajectory b){ if(a.getDimension()!=b.getDimension()){ throw new IllegalArgumentException("Combination not possible: The trajectorys does not have the same dimension"); } if(a.size()!=b.size()){ throw new IllegalArgumentException("Combination not possible: The trajectorys does not " + "have the same number of steps a="+a.size() + " b="+b.size()); } Trajectory c = new Trajectory(a.getDimension()); for(int i = 0 ; i < a.size(); i++){ Point3d pos = new Point3d(a.get(i).x+b.get(i).x, a.get(i).y+b.get(i).y, a.get(i).z+b.get(i).z); c.add(pos); } return c; }
[ "public", "static", "Trajectory", "combineTrajectory", "(", "Trajectory", "a", ",", "Trajectory", "b", ")", "{", "if", "(", "a", ".", "getDimension", "(", ")", "!=", "b", ".", "getDimension", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Combination not possible: The trajectorys does not have the same dimension\"", ")", ";", "}", "if", "(", "a", ".", "size", "(", ")", "!=", "b", ".", "size", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Combination not possible: The trajectorys does not \"", "+", "\"have the same number of steps a=\"", "+", "a", ".", "size", "(", ")", "+", "\" b=\"", "+", "b", ".", "size", "(", ")", ")", ";", "}", "Trajectory", "c", "=", "new", "Trajectory", "(", "a", ".", "getDimension", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "a", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Point3d", "pos", "=", "new", "Point3d", "(", "a", ".", "get", "(", "i", ")", ".", "x", "+", "b", ".", "get", "(", "i", ")", ".", "x", ",", "a", ".", "get", "(", "i", ")", ".", "y", "+", "b", ".", "get", "(", "i", ")", ".", "y", ",", "a", ".", "get", "(", "i", ")", ".", "z", "+", "b", ".", "get", "(", "i", ")", ".", "z", ")", ";", "c", ".", "add", "(", "pos", ")", ";", "}", "return", "c", ";", "}" ]
Combines two trajectories by adding the corresponding positions. The trajectories have to have the same length. @param a The first trajectory @param b The second trajectory @return The combined trajectory
[ "Combines", "two", "trajectories", "by", "adding", "the", "corresponding", "positions", ".", "The", "trajectories", "have", "to", "have", "the", "same", "length", "." ]
505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb
https://github.com/thorstenwagner/TraJ/blob/505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb/src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java#L45-L63
train
thorstenwagner/TraJ
src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java
TrajectoryUtil.concactTrajectorie
public static Trajectory concactTrajectorie(Trajectory a, Trajectory b){ if(a.getDimension()!=b.getDimension()){ throw new IllegalArgumentException("Combination not possible: The trajectorys does not have the same dimension"); } Trajectory c = new Trajectory(a.getDimension()); for(int i = 0 ; i < a.size(); i++){ Point3d pos = new Point3d(a.get(i).x, a.get(i).y, a.get(i).z); c.add(pos); } double dx = a.get(a.size()-1).x - b.get(0).x; double dy = a.get(a.size()-1).y - b.get(0).y; double dz = a.get(a.size()-1).z - b.get(0).z; for(int i = 1 ; i < b.size(); i++){ Point3d pos = new Point3d(b.get(i).x+dx, b.get(i).y+dy, b.get(i).z+dz); c.add(pos); } return c; }
java
public static Trajectory concactTrajectorie(Trajectory a, Trajectory b){ if(a.getDimension()!=b.getDimension()){ throw new IllegalArgumentException("Combination not possible: The trajectorys does not have the same dimension"); } Trajectory c = new Trajectory(a.getDimension()); for(int i = 0 ; i < a.size(); i++){ Point3d pos = new Point3d(a.get(i).x, a.get(i).y, a.get(i).z); c.add(pos); } double dx = a.get(a.size()-1).x - b.get(0).x; double dy = a.get(a.size()-1).y - b.get(0).y; double dz = a.get(a.size()-1).z - b.get(0).z; for(int i = 1 ; i < b.size(); i++){ Point3d pos = new Point3d(b.get(i).x+dx, b.get(i).y+dy, b.get(i).z+dz); c.add(pos); } return c; }
[ "public", "static", "Trajectory", "concactTrajectorie", "(", "Trajectory", "a", ",", "Trajectory", "b", ")", "{", "if", "(", "a", ".", "getDimension", "(", ")", "!=", "b", ".", "getDimension", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Combination not possible: The trajectorys does not have the same dimension\"", ")", ";", "}", "Trajectory", "c", "=", "new", "Trajectory", "(", "a", ".", "getDimension", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "a", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Point3d", "pos", "=", "new", "Point3d", "(", "a", ".", "get", "(", "i", ")", ".", "x", ",", "a", ".", "get", "(", "i", ")", ".", "y", ",", "a", ".", "get", "(", "i", ")", ".", "z", ")", ";", "c", ".", "add", "(", "pos", ")", ";", "}", "double", "dx", "=", "a", ".", "get", "(", "a", ".", "size", "(", ")", "-", "1", ")", ".", "x", "-", "b", ".", "get", "(", "0", ")", ".", "x", ";", "double", "dy", "=", "a", ".", "get", "(", "a", ".", "size", "(", ")", "-", "1", ")", ".", "y", "-", "b", ".", "get", "(", "0", ")", ".", "y", ";", "double", "dz", "=", "a", ".", "get", "(", "a", ".", "size", "(", ")", "-", "1", ")", ".", "z", "-", "b", ".", "get", "(", "0", ")", ".", "z", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "b", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Point3d", "pos", "=", "new", "Point3d", "(", "b", ".", "get", "(", "i", ")", ".", "x", "+", "dx", ",", "b", ".", "get", "(", "i", ")", ".", "y", "+", "dy", ",", "b", ".", "get", "(", "i", ")", ".", "z", "+", "dz", ")", ";", "c", ".", "add", "(", "pos", ")", ";", "}", "return", "c", ";", "}" ]
Concatenates the trajectory a and b @param a The end of this trajectory will be connected to the start of trajectory b @param b The start of this trajectory will be connected to the end of trajectory a @return Concatenated trajectory
[ "Concatenates", "the", "trajectory", "a", "and", "b" ]
505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb
https://github.com/thorstenwagner/TraJ/blob/505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb/src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java#L71-L97
train
thorstenwagner/TraJ
src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java
TrajectoryUtil.resample
public static Trajectory resample(Trajectory t, int n){ Trajectory t1 = new Trajectory(2); for(int i = 0; i < t.size(); i=i+n){ t1.add(t.get(i)); } return t1; }
java
public static Trajectory resample(Trajectory t, int n){ Trajectory t1 = new Trajectory(2); for(int i = 0; i < t.size(); i=i+n){ t1.add(t.get(i)); } return t1; }
[ "public", "static", "Trajectory", "resample", "(", "Trajectory", "t", ",", "int", "n", ")", "{", "Trajectory", "t1", "=", "new", "Trajectory", "(", "2", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "t", ".", "size", "(", ")", ";", "i", "=", "i", "+", "n", ")", "{", "t1", ".", "add", "(", "t", ".", "get", "(", "i", ")", ")", ";", "}", "return", "t1", ";", "}" ]
Resamples a trajectory @param t Trajectory to resample @param n Resample rate @return Returns a resampled trajectory which contains every n'th position of t
[ "Resamples", "a", "trajectory" ]
505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb
https://github.com/thorstenwagner/TraJ/blob/505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb/src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java#L105-L113
train
thorstenwagner/TraJ
src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java
TrajectoryUtil.getTrajectoryByID
public static Trajectory getTrajectoryByID(List<? extends Trajectory> t, int id){ Trajectory track = null; for(int i = 0; i < t.size() ; i++){ if(t.get(i).getID()==id){ track = t.get(i); break; } } return track; }
java
public static Trajectory getTrajectoryByID(List<? extends Trajectory> t, int id){ Trajectory track = null; for(int i = 0; i < t.size() ; i++){ if(t.get(i).getID()==id){ track = t.get(i); break; } } return track; }
[ "public", "static", "Trajectory", "getTrajectoryByID", "(", "List", "<", "?", "extends", "Trajectory", ">", "t", ",", "int", "id", ")", "{", "Trajectory", "track", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "t", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "t", ".", "get", "(", "i", ")", ".", "getID", "(", ")", "==", "id", ")", "{", "track", "=", "t", ".", "get", "(", "i", ")", ";", "break", ";", "}", "}", "return", "track", ";", "}" ]
Finds trajectory by ID @param t List of Trajectories @param id ID of the trajectorie @return Trajectory with ID=id
[ "Finds", "trajectory", "by", "ID" ]
505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb
https://github.com/thorstenwagner/TraJ/blob/505fafb1f2f77a2d67bb2a089a2fdebe2c9bc7cb/src/main/java/de/biomedical_imaging/traJ/TrajectoryUtil.java#L164-L173
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/converters/beans/BeanPropertyTypeProvider.java
BeanPropertyTypeProvider.setPropertyDestinationType
public void setPropertyDestinationType(Class<?> clazz, String propertyName, TypeReference<?> destinationType) { propertiesDestinationTypes.put(new ClassProperty(clazz, propertyName), destinationType); }
java
public void setPropertyDestinationType(Class<?> clazz, String propertyName, TypeReference<?> destinationType) { propertiesDestinationTypes.put(new ClassProperty(clazz, propertyName), destinationType); }
[ "public", "void", "setPropertyDestinationType", "(", "Class", "<", "?", ">", "clazz", ",", "String", "propertyName", ",", "TypeReference", "<", "?", ">", "destinationType", ")", "{", "propertiesDestinationTypes", ".", "put", "(", "new", "ClassProperty", "(", "clazz", ",", "propertyName", ")", ",", "destinationType", ")", ";", "}" ]
set the property destination type for given property @param propertyName @param destinationType
[ "set", "the", "property", "destination", "type", "for", "given", "property" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/beans/BeanPropertyTypeProvider.java#L40-L43
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/converters/MultiConverter.java
MultiConverter.addConverter
public void addConverter(int index, IConverter converter) { converterList.add(index, converter); if (converter instanceof IContainerConverter) { IContainerConverter containerConverter = (IContainerConverter) converter; if (containerConverter.getElementConverter() == null) { containerConverter.setElementConverter(elementConverter); } } }
java
public void addConverter(int index, IConverter converter) { converterList.add(index, converter); if (converter instanceof IContainerConverter) { IContainerConverter containerConverter = (IContainerConverter) converter; if (containerConverter.getElementConverter() == null) { containerConverter.setElementConverter(elementConverter); } } }
[ "public", "void", "addConverter", "(", "int", "index", ",", "IConverter", "converter", ")", "{", "converterList", ".", "add", "(", "index", ",", "converter", ")", ";", "if", "(", "converter", "instanceof", "IContainerConverter", ")", "{", "IContainerConverter", "containerConverter", "=", "(", "IContainerConverter", ")", "converter", ";", "if", "(", "containerConverter", ".", "getElementConverter", "(", ")", "==", "null", ")", "{", "containerConverter", ".", "setElementConverter", "(", "elementConverter", ")", ";", "}", "}", "}" ]
add converter at given index. The index can be changed during conversion if canReorder is true @param index @param converter
[ "add", "converter", "at", "given", "index", ".", "The", "index", "can", "be", "changed", "during", "conversion", "if", "canReorder", "is", "true" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/MultiConverter.java#L60-L68
train
jbossws/jbossws-spi
src/main/java/org/jboss/wsf/spi/SPIProviderResolver.java
SPIProviderResolver.getInstance
public static SPIProviderResolver getInstance(ClassLoader cl) { SPIProviderResolver resolver = (SPIProviderResolver)ServiceLoader.loadService(SPIProviderResolver.class.getName(), DEFAULT_SPI_PROVIDER_RESOLVER, cl); return resolver; }
java
public static SPIProviderResolver getInstance(ClassLoader cl) { SPIProviderResolver resolver = (SPIProviderResolver)ServiceLoader.loadService(SPIProviderResolver.class.getName(), DEFAULT_SPI_PROVIDER_RESOLVER, cl); return resolver; }
[ "public", "static", "SPIProviderResolver", "getInstance", "(", "ClassLoader", "cl", ")", "{", "SPIProviderResolver", "resolver", "=", "(", "SPIProviderResolver", ")", "ServiceLoader", ".", "loadService", "(", "SPIProviderResolver", ".", "class", ".", "getName", "(", ")", ",", "DEFAULT_SPI_PROVIDER_RESOLVER", ",", "cl", ")", ";", "return", "resolver", ";", "}" ]
Get the SPIProviderResolver instance using the provided classloader for lookup @param cl classloader to use for lookup @return instance of this class
[ "Get", "the", "SPIProviderResolver", "instance", "using", "the", "provided", "classloader", "for", "lookup" ]
845e66c18679ce3aaf76f849822110b4650a9d78
https://github.com/jbossws/jbossws-spi/blob/845e66c18679ce3aaf76f849822110b4650a9d78/src/main/java/org/jboss/wsf/spi/SPIProviderResolver.java#L52-L56
train
httpcache4j/httpcache4j
httpcache4j-api/src/main/java/org/codehaus/httpcache4j/util/DirectivesParser.java
DirectivesParser.createParameter
static Parameter createParameter(final String name, final String value) { if (value != null && isQuoted(value)) { return new QuotedParameter(name, value); } return new Parameter(name, value); }
java
static Parameter createParameter(final String name, final String value) { if (value != null && isQuoted(value)) { return new QuotedParameter(name, value); } return new Parameter(name, value); }
[ "static", "Parameter", "createParameter", "(", "final", "String", "name", ",", "final", "String", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "isQuoted", "(", "value", ")", ")", "{", "return", "new", "QuotedParameter", "(", "name", ",", "value", ")", ";", "}", "return", "new", "Parameter", "(", "name", ",", "value", ")", ";", "}" ]
Creates a Parameter @param name the name @param value the value, or <code>null</code> @return a name-value pair representing the arguments
[ "Creates", "a", "Parameter" ]
9c07ebd63cd104a99eb9e771f760f14efa4fe0f6
https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/util/DirectivesParser.java#L256-L261
train
Canadensys/canadensys-core
src/main/java/net/canadensys/utils/LangUtils.java
LangUtils.getClassAnnotationValue
public static <T, A extends Annotation> String getClassAnnotationValue(Class<T> classType, Class<A> annotationType, String attributeName) { String value = null; Annotation annotation = classType.getAnnotation(annotationType); if (annotation != null) { try { value = (String) annotation.annotationType().getMethod(attributeName).invoke(annotation); } catch (Exception ex) {} } return value; }
java
public static <T, A extends Annotation> String getClassAnnotationValue(Class<T> classType, Class<A> annotationType, String attributeName) { String value = null; Annotation annotation = classType.getAnnotation(annotationType); if (annotation != null) { try { value = (String) annotation.annotationType().getMethod(attributeName).invoke(annotation); } catch (Exception ex) {} } return value; }
[ "public", "static", "<", "T", ",", "A", "extends", "Annotation", ">", "String", "getClassAnnotationValue", "(", "Class", "<", "T", ">", "classType", ",", "Class", "<", "A", ">", "annotationType", ",", "String", "attributeName", ")", "{", "String", "value", "=", "null", ";", "Annotation", "annotation", "=", "classType", ".", "getAnnotation", "(", "annotationType", ")", ";", "if", "(", "annotation", "!=", "null", ")", "{", "try", "{", "value", "=", "(", "String", ")", "annotation", ".", "annotationType", "(", ")", ".", "getMethod", "(", "attributeName", ")", ".", "invoke", "(", "annotation", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "}", "}", "return", "value", ";", "}" ]
Get the value of a Annotation in a class declaration. @param classType @param annotationType @param attributeName @return the value of the annotation as String or null if something goes wrong
[ "Get", "the", "value", "of", "a", "Annotation", "in", "a", "class", "declaration", "." ]
5e13569f7c0f4cdc7080da72643ff61123ad76fd
https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/LangUtils.java#L19-L28
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCDateBoxImplHtml5.java
UTCDateBoxImplHtml5.string2long
private Long string2long(String text, DateTimeFormat fmt) { // null or "" returns null if (text == null) return null; text = text.trim(); if (text.length() == 0) return null; Date date = fmt.parse(text); return date != null ? UTCDateBox.date2utc(date) : null; }
java
private Long string2long(String text, DateTimeFormat fmt) { // null or "" returns null if (text == null) return null; text = text.trim(); if (text.length() == 0) return null; Date date = fmt.parse(text); return date != null ? UTCDateBox.date2utc(date) : null; }
[ "private", "Long", "string2long", "(", "String", "text", ",", "DateTimeFormat", "fmt", ")", "{", "// null or \"\" returns null", "if", "(", "text", "==", "null", ")", "return", "null", ";", "text", "=", "text", ".", "trim", "(", ")", ";", "if", "(", "text", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "Date", "date", "=", "fmt", ".", "parse", "(", "text", ")", ";", "return", "date", "!=", "null", "?", "UTCDateBox", ".", "date2utc", "(", "date", ")", ":", "null", ";", "}" ]
Parses the supplied text and converts it to a Long corresponding to that midnight in UTC on the specified date. @return null if it fails to parsing using the specified DateTimeFormat
[ "Parses", "the", "supplied", "text", "and", "converts", "it", "to", "a", "Long", "corresponding", "to", "that", "midnight", "in", "UTC", "on", "the", "specified", "date", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCDateBoxImplHtml5.java#L136-L145
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCDateBoxImplHtml5.java
UTCDateBoxImplHtml5.long2string
private String long2string(Long value, DateTimeFormat fmt) { // for html5 inputs, use "" for no value if (value == null) return ""; Date date = UTCDateBox.utc2date(value); return date != null ? fmt.format(date) : null; }
java
private String long2string(Long value, DateTimeFormat fmt) { // for html5 inputs, use "" for no value if (value == null) return ""; Date date = UTCDateBox.utc2date(value); return date != null ? fmt.format(date) : null; }
[ "private", "String", "long2string", "(", "Long", "value", ",", "DateTimeFormat", "fmt", ")", "{", "// for html5 inputs, use \"\" for no value", "if", "(", "value", "==", "null", ")", "return", "\"\"", ";", "Date", "date", "=", "UTCDateBox", ".", "utc2date", "(", "value", ")", ";", "return", "date", "!=", "null", "?", "fmt", ".", "format", "(", "date", ")", ":", "null", ";", "}" ]
Formats the supplied value using the specified DateTimeFormat. @return "" if the value is null
[ "Formats", "the", "supplied", "value", "using", "the", "specified", "DateTimeFormat", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCDateBoxImplHtml5.java#L152-L157
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.from
public static RgbaColor from(String color) { if (color.startsWith("#")) { return fromHex(color); } else if (color.startsWith("rgba")) { return fromRgba(color); } else if (color.startsWith("rgb")) { return fromRgb(color); } else if (color.startsWith("hsla")) { return fromHsla(color); } else if (color.startsWith("hsl")) { return fromHsl(color); } else { return getDefaultColor(); } }
java
public static RgbaColor from(String color) { if (color.startsWith("#")) { return fromHex(color); } else if (color.startsWith("rgba")) { return fromRgba(color); } else if (color.startsWith("rgb")) { return fromRgb(color); } else if (color.startsWith("hsla")) { return fromHsla(color); } else if (color.startsWith("hsl")) { return fromHsl(color); } else { return getDefaultColor(); } }
[ "public", "static", "RgbaColor", "from", "(", "String", "color", ")", "{", "if", "(", "color", ".", "startsWith", "(", "\"#\"", ")", ")", "{", "return", "fromHex", "(", "color", ")", ";", "}", "else", "if", "(", "color", ".", "startsWith", "(", "\"rgba\"", ")", ")", "{", "return", "fromRgba", "(", "color", ")", ";", "}", "else", "if", "(", "color", ".", "startsWith", "(", "\"rgb\"", ")", ")", "{", "return", "fromRgb", "(", "color", ")", ";", "}", "else", "if", "(", "color", ".", "startsWith", "(", "\"hsla\"", ")", ")", "{", "return", "fromHsla", "(", "color", ")", ";", "}", "else", "if", "(", "color", ".", "startsWith", "(", "\"hsl\"", ")", ")", "{", "return", "fromHsl", "(", "color", ")", ";", "}", "else", "{", "return", "getDefaultColor", "(", ")", ";", "}", "}" ]
Parses an RgbaColor from a hexadecimal, rgb, rgba, hsl, or hsla value. @return returns the parsed color
[ "Parses", "an", "RgbaColor", "from", "a", "hexadecimal", "rgb", "rgba", "hsl", "or", "hsla", "value", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L81-L100
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.fromHex
public static RgbaColor fromHex(String hex) { if (hex.length() == 0 || hex.charAt(0) != '#') return getDefaultColor(); // #rgb if (hex.length() == 4) { return new RgbaColor(parseHex(hex, 1, 2), parseHex(hex, 2, 3), parseHex(hex, 3, 4)); } // #rrggbb else if (hex.length() == 7) { return new RgbaColor(parseHex(hex, 1, 3), parseHex(hex, 3, 5), parseHex(hex, 5, 7)); } else { return getDefaultColor(); } }
java
public static RgbaColor fromHex(String hex) { if (hex.length() == 0 || hex.charAt(0) != '#') return getDefaultColor(); // #rgb if (hex.length() == 4) { return new RgbaColor(parseHex(hex, 1, 2), parseHex(hex, 2, 3), parseHex(hex, 3, 4)); } // #rrggbb else if (hex.length() == 7) { return new RgbaColor(parseHex(hex, 1, 3), parseHex(hex, 3, 5), parseHex(hex, 5, 7)); } else { return getDefaultColor(); } }
[ "public", "static", "RgbaColor", "fromHex", "(", "String", "hex", ")", "{", "if", "(", "hex", ".", "length", "(", ")", "==", "0", "||", "hex", ".", "charAt", "(", "0", ")", "!=", "'", "'", ")", "return", "getDefaultColor", "(", ")", ";", "// #rgb", "if", "(", "hex", ".", "length", "(", ")", "==", "4", ")", "{", "return", "new", "RgbaColor", "(", "parseHex", "(", "hex", ",", "1", ",", "2", ")", ",", "parseHex", "(", "hex", ",", "2", ",", "3", ")", ",", "parseHex", "(", "hex", ",", "3", ",", "4", ")", ")", ";", "}", "// #rrggbb", "else", "if", "(", "hex", ".", "length", "(", ")", "==", "7", ")", "{", "return", "new", "RgbaColor", "(", "parseHex", "(", "hex", ",", "1", ",", "3", ")", ",", "parseHex", "(", "hex", ",", "3", ",", "5", ")", ",", "parseHex", "(", "hex", ",", "5", ",", "7", ")", ")", ";", "}", "else", "{", "return", "getDefaultColor", "(", ")", ";", "}", "}" ]
Parses an RgbaColor from a hexadecimal value. @return returns the parsed color
[ "Parses", "an", "RgbaColor", "from", "a", "hexadecimal", "value", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L107-L129
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.fromRgb
public static RgbaColor fromRgb(String rgb) { if (rgb.length() == 0) return getDefaultColor(); String[] parts = getRgbParts(rgb).split(","); if (parts.length == 3) { return new RgbaColor(parseInt(parts[0]), parseInt(parts[1]), parseInt(parts[2])); } else { return getDefaultColor(); } }
java
public static RgbaColor fromRgb(String rgb) { if (rgb.length() == 0) return getDefaultColor(); String[] parts = getRgbParts(rgb).split(","); if (parts.length == 3) { return new RgbaColor(parseInt(parts[0]), parseInt(parts[1]), parseInt(parts[2])); } else { return getDefaultColor(); } }
[ "public", "static", "RgbaColor", "fromRgb", "(", "String", "rgb", ")", "{", "if", "(", "rgb", ".", "length", "(", ")", "==", "0", ")", "return", "getDefaultColor", "(", ")", ";", "String", "[", "]", "parts", "=", "getRgbParts", "(", "rgb", ")", ".", "split", "(", "\",\"", ")", ";", "if", "(", "parts", ".", "length", "==", "3", ")", "{", "return", "new", "RgbaColor", "(", "parseInt", "(", "parts", "[", "0", "]", ")", ",", "parseInt", "(", "parts", "[", "1", "]", ")", ",", "parseInt", "(", "parts", "[", "2", "]", ")", ")", ";", "}", "else", "{", "return", "getDefaultColor", "(", ")", ";", "}", "}" ]
Parses an RgbaColor from an rgb value. @return the parsed color
[ "Parses", "an", "RgbaColor", "from", "an", "rgb", "value", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L136-L148
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.fromRgba
public static RgbaColor fromRgba(String rgba) { if (rgba.length() == 0) return getDefaultColor(); String[] parts = getRgbaParts(rgba).split(","); if (parts.length == 4) { return new RgbaColor(parseInt(parts[0]), parseInt(parts[1]), parseInt(parts[2]), parseFloat(parts[3])); } else { return getDefaultColor(); } }
java
public static RgbaColor fromRgba(String rgba) { if (rgba.length() == 0) return getDefaultColor(); String[] parts = getRgbaParts(rgba).split(","); if (parts.length == 4) { return new RgbaColor(parseInt(parts[0]), parseInt(parts[1]), parseInt(parts[2]), parseFloat(parts[3])); } else { return getDefaultColor(); } }
[ "public", "static", "RgbaColor", "fromRgba", "(", "String", "rgba", ")", "{", "if", "(", "rgba", ".", "length", "(", ")", "==", "0", ")", "return", "getDefaultColor", "(", ")", ";", "String", "[", "]", "parts", "=", "getRgbaParts", "(", "rgba", ")", ".", "split", "(", "\",\"", ")", ";", "if", "(", "parts", ".", "length", "==", "4", ")", "{", "return", "new", "RgbaColor", "(", "parseInt", "(", "parts", "[", "0", "]", ")", ",", "parseInt", "(", "parts", "[", "1", "]", ")", ",", "parseInt", "(", "parts", "[", "2", "]", ")", ",", "parseFloat", "(", "parts", "[", "3", "]", ")", ")", ";", "}", "else", "{", "return", "getDefaultColor", "(", ")", ";", "}", "}" ]
Parses an RgbaColor from an rgba value. @return the parsed color
[ "Parses", "an", "RgbaColor", "from", "an", "rgba", "value", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L155-L168
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.withHsl
private RgbaColor withHsl(int index, float value) { float[] HSL = convertToHsl(); HSL[index] = value; return RgbaColor.fromHsl(HSL); }
java
private RgbaColor withHsl(int index, float value) { float[] HSL = convertToHsl(); HSL[index] = value; return RgbaColor.fromHsl(HSL); }
[ "private", "RgbaColor", "withHsl", "(", "int", "index", ",", "float", "value", ")", "{", "float", "[", "]", "HSL", "=", "convertToHsl", "(", ")", ";", "HSL", "[", "index", "]", "=", "value", ";", "return", "RgbaColor", ".", "fromHsl", "(", "HSL", ")", ";", "}" ]
Returns a new color with a new value of the specified HSL component.
[ "Returns", "a", "new", "color", "with", "a", "new", "value", "of", "the", "specified", "HSL", "component", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L389-L393
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.adjustHue
public RgbaColor adjustHue(float degrees) { float[] HSL = convertToHsl(); HSL[0] = hueCheck(HSL[0] + degrees); // ensure [0-360) return RgbaColor.fromHsl(HSL); }
java
public RgbaColor adjustHue(float degrees) { float[] HSL = convertToHsl(); HSL[0] = hueCheck(HSL[0] + degrees); // ensure [0-360) return RgbaColor.fromHsl(HSL); }
[ "public", "RgbaColor", "adjustHue", "(", "float", "degrees", ")", "{", "float", "[", "]", "HSL", "=", "convertToHsl", "(", ")", ";", "HSL", "[", "0", "]", "=", "hueCheck", "(", "HSL", "[", "0", "]", "+", "degrees", ")", ";", "// ensure [0-360)", "return", "RgbaColor", ".", "fromHsl", "(", "HSL", ")", ";", "}" ]
Returns a new color that has the hue adjusted by the specified amount.
[ "Returns", "a", "new", "color", "that", "has", "the", "hue", "adjusted", "by", "the", "specified", "amount", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L429-L433
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.opacify
public RgbaColor opacify(float amount) { return new RgbaColor(r, g, b, alphaCheck(a + amount)); }
java
public RgbaColor opacify(float amount) { return new RgbaColor(r, g, b, alphaCheck(a + amount)); }
[ "public", "RgbaColor", "opacify", "(", "float", "amount", ")", "{", "return", "new", "RgbaColor", "(", "r", ",", "g", ",", "b", ",", "alphaCheck", "(", "a", "+", "amount", ")", ")", ";", "}" ]
Returns a new color that has the alpha adjusted by the specified amount.
[ "Returns", "a", "new", "color", "that", "has", "the", "alpha", "adjusted", "by", "the", "specified", "amount", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L439-L441
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.getSpreadInRange
protected static final float[] getSpreadInRange(float member, int count, int max, int offset) { // to find the spread, we first find the min that is a // multiple of max/count away from the member int interval = max / count; float min = (member + offset) % interval; if (min == 0 && member == max) { min += interval; } float[] range = new float[count]; for (int i = 0; i < count; i++) { range[i] = min + interval * i + offset; } return range; }
java
protected static final float[] getSpreadInRange(float member, int count, int max, int offset) { // to find the spread, we first find the min that is a // multiple of max/count away from the member int interval = max / count; float min = (member + offset) % interval; if (min == 0 && member == max) { min += interval; } float[] range = new float[count]; for (int i = 0; i < count; i++) { range[i] = min + interval * i + offset; } return range; }
[ "protected", "static", "final", "float", "[", "]", "getSpreadInRange", "(", "float", "member", ",", "int", "count", ",", "int", "max", ",", "int", "offset", ")", "{", "// to find the spread, we first find the min that is a", "// multiple of max/count away from the member", "int", "interval", "=", "max", "/", "count", ";", "float", "min", "=", "(", "member", "+", "offset", ")", "%", "interval", ";", "if", "(", "min", "==", "0", "&&", "member", "==", "max", ")", "{", "min", "+=", "interval", ";", "}", "float", "[", "]", "range", "=", "new", "float", "[", "count", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "range", "[", "i", "]", "=", "min", "+", "interval", "*", "i", "+", "offset", ";", "}", "return", "range", ";", "}" ]
Returns a spread of integers in a range [0,max) that includes count. The spread is sorted from largest to smallest.
[ "Returns", "a", "spread", "of", "integers", "in", "a", "range", "[", "0", "max", ")", "that", "includes", "count", ".", "The", "spread", "is", "sorted", "from", "largest", "to", "smallest", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L509-L526
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.fromHsl
public static RgbaColor fromHsl(float H, float S, float L) { // convert to [0-1] H /= 360f; S /= 100f; L /= 100f; float R, G, B; if (S == 0) { // grey R = G = B = L; } else { float m2 = L <= 0.5 ? L * (S + 1f) : L + S - L * S; float m1 = 2f * L - m2; R = hue2rgb(m1, m2, H + 1 / 3f); G = hue2rgb(m1, m2, H); B = hue2rgb(m1, m2, H - 1 / 3f); } // convert [0-1] to [0-255] int r = Math.round(R * 255f); int g = Math.round(G * 255f); int b = Math.round(B * 255f); return new RgbaColor(r, g, b, 1); }
java
public static RgbaColor fromHsl(float H, float S, float L) { // convert to [0-1] H /= 360f; S /= 100f; L /= 100f; float R, G, B; if (S == 0) { // grey R = G = B = L; } else { float m2 = L <= 0.5 ? L * (S + 1f) : L + S - L * S; float m1 = 2f * L - m2; R = hue2rgb(m1, m2, H + 1 / 3f); G = hue2rgb(m1, m2, H); B = hue2rgb(m1, m2, H - 1 / 3f); } // convert [0-1] to [0-255] int r = Math.round(R * 255f); int g = Math.round(G * 255f); int b = Math.round(B * 255f); return new RgbaColor(r, g, b, 1); }
[ "public", "static", "RgbaColor", "fromHsl", "(", "float", "H", ",", "float", "S", ",", "float", "L", ")", "{", "// convert to [0-1]", "H", "/=", "360f", ";", "S", "/=", "100f", ";", "L", "/=", "100f", ";", "float", "R", ",", "G", ",", "B", ";", "if", "(", "S", "==", "0", ")", "{", "// grey", "R", "=", "G", "=", "B", "=", "L", ";", "}", "else", "{", "float", "m2", "=", "L", "<=", "0.5", "?", "L", "*", "(", "S", "+", "1f", ")", ":", "L", "+", "S", "-", "L", "*", "S", ";", "float", "m1", "=", "2f", "*", "L", "-", "m2", ";", "R", "=", "hue2rgb", "(", "m1", ",", "m2", ",", "H", "+", "1", "/", "3f", ")", ";", "G", "=", "hue2rgb", "(", "m1", ",", "m2", ",", "H", ")", ";", "B", "=", "hue2rgb", "(", "m1", ",", "m2", ",", "H", "-", "1", "/", "3f", ")", ";", "}", "// convert [0-1] to [0-255]", "int", "r", "=", "Math", ".", "round", "(", "R", "*", "255f", ")", ";", "int", "g", "=", "Math", ".", "round", "(", "G", "*", "255f", ")", ";", "int", "b", "=", "Math", ".", "round", "(", "B", "*", "255f", ")", ";", "return", "new", "RgbaColor", "(", "r", ",", "g", ",", "b", ",", "1", ")", ";", "}" ]
Creates a new RgbaColor from the specified HSL components. <p> <i>Implementation based on <a href="http://en.wikipedia.org/wiki/HSL_and_HSV">wikipedia</a> and <a href="http://www.w3.org/TR/css3-color/#hsl-color">w3c</a></i> @param H Hue [0,360) @param S Saturation [0,100] @param L Lightness [0,100]
[ "Creates", "a", "new", "RgbaColor", "from", "the", "specified", "HSL", "components", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L673-L700
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
RgbaColor.max
private float max(float x, float y, float z) { if (x > y) { // not y if (x > z) { return x; } else { return z; } } else { // not x if (y > z) { return y; } else { return z; } } }
java
private float max(float x, float y, float z) { if (x > y) { // not y if (x > z) { return x; } else { return z; } } else { // not x if (y > z) { return y; } else { return z; } } }
[ "private", "float", "max", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "if", "(", "x", ">", "y", ")", "{", "// not y", "if", "(", "x", ">", "z", ")", "{", "return", "x", ";", "}", "else", "{", "return", "z", ";", "}", "}", "else", "{", "// not x", "if", "(", "y", ">", "z", ")", "{", "return", "y", ";", "}", "else", "{", "return", "z", ";", "}", "}", "}" ]
misc utility methods
[ "misc", "utility", "methods" ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L826-L845
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/converters/ObjectToObjectUsingConstructor.java
ObjectToObjectUsingConstructor.getCompatibleConstructor
public Constructor<?> getCompatibleConstructor(Class<?> type, Class<?> argumentType) { try { return type.getConstructor(new Class[] { argumentType }); } catch (Exception e) { // get public classes and interfaces Class<?>[] types = type.getClasses(); for (int i = 0; i < types.length; i++) { try { return type.getConstructor(new Class[] { types[i] }); } catch (Exception e1) { } } } return null; }
java
public Constructor<?> getCompatibleConstructor(Class<?> type, Class<?> argumentType) { try { return type.getConstructor(new Class[] { argumentType }); } catch (Exception e) { // get public classes and interfaces Class<?>[] types = type.getClasses(); for (int i = 0; i < types.length; i++) { try { return type.getConstructor(new Class[] { types[i] }); } catch (Exception e1) { } } } return null; }
[ "public", "Constructor", "<", "?", ">", "getCompatibleConstructor", "(", "Class", "<", "?", ">", "type", ",", "Class", "<", "?", ">", "argumentType", ")", "{", "try", "{", "return", "type", ".", "getConstructor", "(", "new", "Class", "[", "]", "{", "argumentType", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// get public classes and interfaces\r", "Class", "<", "?", ">", "[", "]", "types", "=", "type", ".", "getClasses", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "types", ".", "length", ";", "i", "++", ")", "{", "try", "{", "return", "type", ".", "getConstructor", "(", "new", "Class", "[", "]", "{", "types", "[", "i", "]", "}", ")", ";", "}", "catch", "(", "Exception", "e1", ")", "{", "}", "}", "}", "return", "null", ";", "}" ]
Get a compatible constructor @param type Class to look for constructor in @param argumentType Argument type for constructor @return the compatible constructor or null if none found
[ "Get", "a", "compatible", "constructor" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/ObjectToObjectUsingConstructor.java#L94-L110
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/Transmorph.java
Transmorph.convert
public <T> T convert(Object source, TypeReference<T> typeReference) throws ConverterException { return (T) convert(new ConversionContext(), source, typeReference); }
java
public <T> T convert(Object source, TypeReference<T> typeReference) throws ConverterException { return (T) convert(new ConversionContext(), source, typeReference); }
[ "public", "<", "T", ">", "T", "convert", "(", "Object", "source", ",", "TypeReference", "<", "T", ">", "typeReference", ")", "throws", "ConverterException", "{", "return", "(", "T", ")", "convert", "(", "new", "ConversionContext", "(", ")", ",", "source", ",", "typeReference", ")", ";", "}" ]
Convert an object to another object with given type @param <T> @param source object to convert @param typeReference reference to {@link java.lang.reflect.Type} @return the converted object if conversion failed @throws ConverterException
[ "Convert", "an", "object", "to", "another", "object", "with", "given", "type" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/Transmorph.java#L77-L80
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/Transmorph.java
Transmorph.convert
public <T> T convert(ConversionContext context, Object source, TypeReference<T> destinationType) throws ConverterException { try { return (T) multiConverter.convert(context, source, destinationType); } catch (ConverterException e) { throw e; } catch (Exception e) { // There is a problem with one converter. This should not happen. // Either there is a bug in this converter or it is not properly // configured throw new ConverterException( MessageFormat .format( "Could not convert given object with class ''{0}'' to object with type signature ''{1}''", source == null ? "null" : source.getClass() .getName(), destinationType), e); } }
java
public <T> T convert(ConversionContext context, Object source, TypeReference<T> destinationType) throws ConverterException { try { return (T) multiConverter.convert(context, source, destinationType); } catch (ConverterException e) { throw e; } catch (Exception e) { // There is a problem with one converter. This should not happen. // Either there is a bug in this converter or it is not properly // configured throw new ConverterException( MessageFormat .format( "Could not convert given object with class ''{0}'' to object with type signature ''{1}''", source == null ? "null" : source.getClass() .getName(), destinationType), e); } }
[ "public", "<", "T", ">", "T", "convert", "(", "ConversionContext", "context", ",", "Object", "source", ",", "TypeReference", "<", "T", ">", "destinationType", ")", "throws", "ConverterException", "{", "try", "{", "return", "(", "T", ")", "multiConverter", ".", "convert", "(", "context", ",", "source", ",", "destinationType", ")", ";", "}", "catch", "(", "ConverterException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// There is a problem with one converter. This should not happen.\r", "// Either there is a bug in this converter or it is not properly\r", "// configured\r", "throw", "new", "ConverterException", "(", "MessageFormat", ".", "format", "(", "\"Could not convert given object with class ''{0}'' to object with type signature ''{1}''\"", ",", "source", "==", "null", "?", "\"null\"", ":", "source", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "destinationType", ")", ",", "e", ")", ";", "}", "}" ]
Convert an object to another object given a parameterized type signature @param context @param destinationType the destination type @param source the source object @return the converted object @throws ConverterException if conversion failed
[ "Convert", "an", "object", "to", "another", "object", "given", "a", "parameterized", "type", "signature" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/Transmorph.java#L145-L162
train
mgormley/optimize
src/main/java/edu/jhu/hlt/util/Utilities.java
Utilities.compare
public static int compare(double a, double b, double delta) { if (equals(a, b, delta)) { return 0; } return Double.compare(a, b); }
java
public static int compare(double a, double b, double delta) { if (equals(a, b, delta)) { return 0; } return Double.compare(a, b); }
[ "public", "static", "int", "compare", "(", "double", "a", ",", "double", "b", ",", "double", "delta", ")", "{", "if", "(", "equals", "(", "a", ",", "b", ",", "delta", ")", ")", "{", "return", "0", ";", "}", "return", "Double", ".", "compare", "(", "a", ",", "b", ")", ";", "}" ]
Compares two double values up to some delta. @param a @param b @param delta @return The value 0 if a equals b, a value greater than 0 if if a > b, and a value less than 0 if a < b.
[ "Compares", "two", "double", "values", "up", "to", "some", "delta", "." ]
3d1b93260b99febb8a5ecd9e8543c223e151a8d3
https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/util/Utilities.java#L483-L488
train
mgormley/optimize
src/main/java/edu/jhu/hlt/optimize/function/AbstractSumBatchFunction.java
AbstractSumBatchFunction.getValue
public double getValue(int[] batch) { double value = 0.0; for (int i=0; i<batch.length; i++) { value += getValue(i); } return value; }
java
public double getValue(int[] batch) { double value = 0.0; for (int i=0; i<batch.length; i++) { value += getValue(i); } return value; }
[ "public", "double", "getValue", "(", "int", "[", "]", "batch", ")", "{", "double", "value", "=", "0.0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "batch", ".", "length", ";", "i", "++", ")", "{", "value", "+=", "getValue", "(", "i", ")", ";", "}", "return", "value", ";", "}" ]
Gets value of this function at the current point, computed on the given batch of examples. @param batch A set of indices indicating the examples over which the gradient should be computed. @return The value of the function at the point.
[ "Gets", "value", "of", "this", "function", "at", "the", "current", "point", "computed", "on", "the", "given", "batch", "of", "examples", "." ]
3d1b93260b99febb8a5ecd9e8543c223e151a8d3
https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/AbstractSumBatchFunction.java#L20-L26
train
mgormley/optimize
src/main/java/edu/jhu/hlt/optimize/function/AbstractSumBatchFunction.java
AbstractSumBatchFunction.getGradient
public void getGradient(int[] batch, double[] gradient) { for (int i=0; i<batch.length; i++) { addGradient(i, gradient); } }
java
public void getGradient(int[] batch, double[] gradient) { for (int i=0; i<batch.length; i++) { addGradient(i, gradient); } }
[ "public", "void", "getGradient", "(", "int", "[", "]", "batch", ",", "double", "[", "]", "gradient", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "batch", ".", "length", ";", "i", "++", ")", "{", "addGradient", "(", "i", ",", "gradient", ")", ";", "}", "}" ]
Gets the gradient at the current point, computed on the given batch of examples. @param batch A set of indices indicating the examples over which the gradient should be computed. @param gradient The output gradient, a vector of partial derivatives.
[ "Gets", "the", "gradient", "at", "the", "current", "point", "computed", "on", "the", "given", "batch", "of", "examples", "." ]
3d1b93260b99febb8a5ecd9e8543c223e151a8d3
https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/AbstractSumBatchFunction.java#L33-L37
train
erickok/RxCupboard
sample/src/main/java/nl/nl2312/rxcupboard2/sample/CupboardDbHelper.java
CupboardDbHelper.getConnection
public synchronized static SQLiteDatabase getConnection(Context context) { if (database == null) { // Construct the single helper and open the unique(!) db connection for the app database = new CupboardDbHelper(context.getApplicationContext()).getWritableDatabase(); } return database; }
java
public synchronized static SQLiteDatabase getConnection(Context context) { if (database == null) { // Construct the single helper and open the unique(!) db connection for the app database = new CupboardDbHelper(context.getApplicationContext()).getWritableDatabase(); } return database; }
[ "public", "synchronized", "static", "SQLiteDatabase", "getConnection", "(", "Context", "context", ")", "{", "if", "(", "database", "==", "null", ")", "{", "// Construct the single helper and open the unique(!) db connection for the app", "database", "=", "new", "CupboardDbHelper", "(", "context", ".", "getApplicationContext", "(", ")", ")", ".", "getWritableDatabase", "(", ")", ";", "}", "return", "database", ";", "}" ]
Returns a raw handle to the SQLite database connection. Do not close! @param context A context, which is used to (when needed) set up a connection to the database @return The single, unique connection to the database, as is (also) used by our Cupboard instance
[ "Returns", "a", "raw", "handle", "to", "the", "SQLite", "database", "connection", ".", "Do", "not", "close!" ]
2c75d880d7aae6d7b86538345b9daa3e438697e8
https://github.com/erickok/RxCupboard/blob/2c75d880d7aae6d7b86538345b9daa3e438697e8/sample/src/main/java/nl/nl2312/rxcupboard2/sample/CupboardDbHelper.java#L28-L34
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeReference.java
TypeReference.getSuperclassTypeParameter
@SuppressWarnings("unchecked") public static Type getSuperclassTypeParameter(Class<?> subclass) { Type superclass = subclass.getGenericSuperclass(); if (superclass instanceof Class) { throw new RuntimeException("Missing type parameter."); } return ((ParameterizedType) superclass).getActualTypeArguments()[0]; }
java
@SuppressWarnings("unchecked") public static Type getSuperclassTypeParameter(Class<?> subclass) { Type superclass = subclass.getGenericSuperclass(); if (superclass instanceof Class) { throw new RuntimeException("Missing type parameter."); } return ((ParameterizedType) superclass).getActualTypeArguments()[0]; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Type", "getSuperclassTypeParameter", "(", "Class", "<", "?", ">", "subclass", ")", "{", "Type", "superclass", "=", "subclass", ".", "getGenericSuperclass", "(", ")", ";", "if", "(", "superclass", "instanceof", "Class", ")", "{", "throw", "new", "RuntimeException", "(", "\"Missing type parameter.\"", ")", ";", "}", "return", "(", "(", "ParameterizedType", ")", "superclass", ")", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "}" ]
Gets type from super class's type parameter.
[ "Gets", "type", "from", "super", "class", "s", "type", "parameter", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeReference.java#L263-L270
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingBase.java
AutoSizingBase.onLoad
@Override protected void onLoad() { super.onLoad(); // these styles need to be the same for the box and shadow so // that we can measure properly matchStyles("display"); matchStyles("fontSize"); matchStyles("fontFamily"); matchStyles("fontWeight"); matchStyles("lineHeight"); matchStyles("paddingTop"); matchStyles("paddingRight"); matchStyles("paddingBottom"); matchStyles("paddingLeft"); adjustSize(); }
java
@Override protected void onLoad() { super.onLoad(); // these styles need to be the same for the box and shadow so // that we can measure properly matchStyles("display"); matchStyles("fontSize"); matchStyles("fontFamily"); matchStyles("fontWeight"); matchStyles("lineHeight"); matchStyles("paddingTop"); matchStyles("paddingRight"); matchStyles("paddingBottom"); matchStyles("paddingLeft"); adjustSize(); }
[ "@", "Override", "protected", "void", "onLoad", "(", ")", "{", "super", ".", "onLoad", "(", ")", ";", "// these styles need to be the same for the box and shadow so", "// that we can measure properly", "matchStyles", "(", "\"display\"", ")", ";", "matchStyles", "(", "\"fontSize\"", ")", ";", "matchStyles", "(", "\"fontFamily\"", ")", ";", "matchStyles", "(", "\"fontWeight\"", ")", ";", "matchStyles", "(", "\"lineHeight\"", ")", ";", "matchStyles", "(", "\"paddingTop\"", ")", ";", "matchStyles", "(", "\"paddingRight\"", ")", ";", "matchStyles", "(", "\"paddingBottom\"", ")", ";", "matchStyles", "(", "\"paddingLeft\"", ")", ";", "adjustSize", "(", ")", ";", "}" ]
Matches the styles and adjusts the size. This needs to be called after the input is added to the DOM, so we do it in onLoad.
[ "Matches", "the", "styles", "and", "adjusts", "the", "size", ".", "This", "needs", "to", "be", "called", "after", "the", "input", "is", "added", "to", "the", "DOM", "so", "we", "do", "it", "in", "onLoad", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingBase.java#L180-L197
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingBase.java
AutoSizingBase.onKeyDown
@Override public void onKeyDown(KeyDownEvent event) { char c = MiscUtils.getCharCode(event.getNativeEvent()); onKeyCodeEvent(event, box.getValue()+c); }
java
@Override public void onKeyDown(KeyDownEvent event) { char c = MiscUtils.getCharCode(event.getNativeEvent()); onKeyCodeEvent(event, box.getValue()+c); }
[ "@", "Override", "public", "void", "onKeyDown", "(", "KeyDownEvent", "event", ")", "{", "char", "c", "=", "MiscUtils", ".", "getCharCode", "(", "event", ".", "getNativeEvent", "(", ")", ")", ";", "onKeyCodeEvent", "(", "event", ",", "box", ".", "getValue", "(", ")", "+", "c", ")", ";", "}" ]
On key down we assume the key will go at the end. It's the most common case and not that distracting if that's not true.
[ "On", "key", "down", "we", "assume", "the", "key", "will", "go", "at", "the", "end", ".", "It", "s", "the", "most", "common", "case", "and", "not", "that", "distracting", "if", "that", "s", "not", "true", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingBase.java#L233-L237
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/util/DomUtils.java
DomUtils.setEnabled
public static void setEnabled(Element element, boolean enabled) { element.setPropertyBoolean("disabled", !enabled); setStyleName(element, "disabled", !enabled); }
java
public static void setEnabled(Element element, boolean enabled) { element.setPropertyBoolean("disabled", !enabled); setStyleName(element, "disabled", !enabled); }
[ "public", "static", "void", "setEnabled", "(", "Element", "element", ",", "boolean", "enabled", ")", "{", "element", ".", "setPropertyBoolean", "(", "\"disabled\"", ",", "!", "enabled", ")", ";", "setStyleName", "(", "element", ",", "\"disabled\"", ",", "!", "enabled", ")", ";", "}" ]
It's enough to just set the disabled attribute on the element, but we want to also add a "disabled" class so that we can style it. At some point we'll just be able to use .button:disabled, but that doesn't work in IE8-
[ "It", "s", "enough", "to", "just", "set", "the", "disabled", "attribute", "on", "the", "element", "but", "we", "want", "to", "also", "add", "a", "disabled", "class", "so", "that", "we", "can", "style", "it", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/DomUtils.java#L45-L48
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/converters/beans/BeanToBean.java
BeanToBean.getPropertySourceMethod
private Method getPropertySourceMethod(Object sourceObject, Object destinationObject, String destinationProperty) { BeanToBeanMapping beanToBeanMapping = beanToBeanMappings.get(ClassPair .get(sourceObject.getClass(), destinationObject .getClass())); String sourceProperty = null; if (beanToBeanMapping != null) { sourceProperty = beanToBeanMapping .getSourceProperty(destinationProperty); } if (sourceProperty == null) { sourceProperty = destinationProperty; } return BeanUtils.getGetterPropertyMethod(sourceObject.getClass(), sourceProperty); }
java
private Method getPropertySourceMethod(Object sourceObject, Object destinationObject, String destinationProperty) { BeanToBeanMapping beanToBeanMapping = beanToBeanMappings.get(ClassPair .get(sourceObject.getClass(), destinationObject .getClass())); String sourceProperty = null; if (beanToBeanMapping != null) { sourceProperty = beanToBeanMapping .getSourceProperty(destinationProperty); } if (sourceProperty == null) { sourceProperty = destinationProperty; } return BeanUtils.getGetterPropertyMethod(sourceObject.getClass(), sourceProperty); }
[ "private", "Method", "getPropertySourceMethod", "(", "Object", "sourceObject", ",", "Object", "destinationObject", ",", "String", "destinationProperty", ")", "{", "BeanToBeanMapping", "beanToBeanMapping", "=", "beanToBeanMappings", ".", "get", "(", "ClassPair", ".", "get", "(", "sourceObject", ".", "getClass", "(", ")", ",", "destinationObject", ".", "getClass", "(", ")", ")", ")", ";", "String", "sourceProperty", "=", "null", ";", "if", "(", "beanToBeanMapping", "!=", "null", ")", "{", "sourceProperty", "=", "beanToBeanMapping", ".", "getSourceProperty", "(", "destinationProperty", ")", ";", "}", "if", "(", "sourceProperty", "==", "null", ")", "{", "sourceProperty", "=", "destinationProperty", ";", "}", "return", "BeanUtils", ".", "getGetterPropertyMethod", "(", "sourceObject", ".", "getClass", "(", ")", ",", "sourceProperty", ")", ";", "}" ]
get the property source method corresponding to given destination property @param sourceObject @param destinationObject @param destinationProperty @return
[ "get", "the", "property", "source", "method", "corresponding", "to", "given", "destination", "property" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/beans/BeanToBean.java#L161-L177
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/converters/beans/BeanToBean.java
BeanToBean.getBeanPropertyType
protected TypeReference<?> getBeanPropertyType(Class<?> clazz, String propertyName, TypeReference<?> originalType) { TypeReference<?> propertyDestinationType = null; if (beanDestinationPropertyTypeProvider != null) { propertyDestinationType = beanDestinationPropertyTypeProvider .getPropertyType(clazz, propertyName, originalType); } if (propertyDestinationType == null) { propertyDestinationType = originalType; } return propertyDestinationType; }
java
protected TypeReference<?> getBeanPropertyType(Class<?> clazz, String propertyName, TypeReference<?> originalType) { TypeReference<?> propertyDestinationType = null; if (beanDestinationPropertyTypeProvider != null) { propertyDestinationType = beanDestinationPropertyTypeProvider .getPropertyType(clazz, propertyName, originalType); } if (propertyDestinationType == null) { propertyDestinationType = originalType; } return propertyDestinationType; }
[ "protected", "TypeReference", "<", "?", ">", "getBeanPropertyType", "(", "Class", "<", "?", ">", "clazz", ",", "String", "propertyName", ",", "TypeReference", "<", "?", ">", "originalType", ")", "{", "TypeReference", "<", "?", ">", "propertyDestinationType", "=", "null", ";", "if", "(", "beanDestinationPropertyTypeProvider", "!=", "null", ")", "{", "propertyDestinationType", "=", "beanDestinationPropertyTypeProvider", ".", "getPropertyType", "(", "clazz", ",", "propertyName", ",", "originalType", ")", ";", "}", "if", "(", "propertyDestinationType", "==", "null", ")", "{", "propertyDestinationType", "=", "originalType", ";", "}", "return", "propertyDestinationType", ";", "}" ]
get the bean property type @param clazz @param propertyName @param originalType @return
[ "get", "the", "bean", "property", "type" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/beans/BeanToBean.java#L187-L198
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/converters/beans/BeanToBean.java
BeanToBean.addBeanToBeanMapping
public void addBeanToBeanMapping(BeanToBeanMapping beanToBeanMapping) { beanToBeanMappings.put(ClassPair.get(beanToBeanMapping .getSourceClass(), beanToBeanMapping.getDestinationClass()), beanToBeanMapping); }
java
public void addBeanToBeanMapping(BeanToBeanMapping beanToBeanMapping) { beanToBeanMappings.put(ClassPair.get(beanToBeanMapping .getSourceClass(), beanToBeanMapping.getDestinationClass()), beanToBeanMapping); }
[ "public", "void", "addBeanToBeanMapping", "(", "BeanToBeanMapping", "beanToBeanMapping", ")", "{", "beanToBeanMappings", ".", "put", "(", "ClassPair", ".", "get", "(", "beanToBeanMapping", ".", "getSourceClass", "(", ")", ",", "beanToBeanMapping", ".", "getDestinationClass", "(", ")", ")", ",", "beanToBeanMapping", ")", ";", "}" ]
Add a mapping of properties between two beans @param beanToBeanMapping
[ "Add", "a", "mapping", "of", "properties", "between", "two", "beans" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/beans/BeanToBean.java#L205-L209
train
jbossws/jbossws-spi
src/main/java/org/jboss/wsf/spi/SPIProvider.java
SPIProvider.getInstance
public static SPIProvider getInstance() { if (me == null) { final ClassLoader cl = ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader(); me = SPIProviderResolver.getInstance(cl).getProvider(); } return me; }
java
public static SPIProvider getInstance() { if (me == null) { final ClassLoader cl = ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader(); me = SPIProviderResolver.getInstance(cl).getProvider(); } return me; }
[ "public", "static", "SPIProvider", "getInstance", "(", ")", "{", "if", "(", "me", "==", "null", ")", "{", "final", "ClassLoader", "cl", "=", "ClassLoaderProvider", ".", "getDefaultProvider", "(", ")", ".", "getServerIntegrationClassLoader", "(", ")", ";", "me", "=", "SPIProviderResolver", ".", "getInstance", "(", "cl", ")", ".", "getProvider", "(", ")", ";", "}", "return", "me", ";", "}" ]
Gets the a singleton reference to the SPIProvider returned by the SPIProviderResolver retrieved using the default server integration classloader. @return this class instance
[ "Gets", "the", "a", "singleton", "reference", "to", "the", "SPIProvider", "returned", "by", "the", "SPIProviderResolver", "retrieved", "using", "the", "default", "server", "integration", "classloader", "." ]
845e66c18679ce3aaf76f849822110b4650a9d78
https://github.com/jbossws/jbossws-spi/blob/845e66c18679ce3aaf76f849822110b4650a9d78/src/main/java/org/jboss/wsf/spi/SPIProvider.java#L42-L50
train
jbossws/jbossws-spi
src/main/java/org/jboss/wsf/spi/SPIProvider.java
SPIProvider.getSPI
public <T> T getSPI(Class<T> spiType) { return getSPI(spiType, SecurityActions.getContextClassLoader()); }
java
public <T> T getSPI(Class<T> spiType) { return getSPI(spiType, SecurityActions.getContextClassLoader()); }
[ "public", "<", "T", ">", "T", "getSPI", "(", "Class", "<", "T", ">", "spiType", ")", "{", "return", "getSPI", "(", "spiType", ",", "SecurityActions", ".", "getContextClassLoader", "(", ")", ")", ";", "}" ]
Gets the specified SPI, using the current thread context classloader @param <T> type of spi class @param spiType spi class to retrieve @return object
[ "Gets", "the", "specified", "SPI", "using", "the", "current", "thread", "context", "classloader" ]
845e66c18679ce3aaf76f849822110b4650a9d78
https://github.com/jbossws/jbossws-spi/blob/845e66c18679ce3aaf76f849822110b4650a9d78/src/main/java/org/jboss/wsf/spi/SPIProvider.java#L59-L62
train
matiwinnetou/spring-soy-view
spring-soy-view/src/main/java/pl/matisoft/soy/bundle/DefaultSoyMsgBundleResolver.java
DefaultSoyMsgBundleResolver.resolve
public Optional<SoyMsgBundle> resolve(final Optional<Locale> locale) throws IOException { if (!locale.isPresent()) { return Optional.absent(); } synchronized (msgBundles) { SoyMsgBundle soyMsgBundle = null; if (isHotReloadModeOff()) { soyMsgBundle = msgBundles.get(locale.get()); } if (soyMsgBundle == null) { soyMsgBundle = createSoyMsgBundle(locale.get()); if (soyMsgBundle == null) { soyMsgBundle = createSoyMsgBundle(new Locale(locale.get().getLanguage())); } if (soyMsgBundle == null && fallbackToEnglish) { soyMsgBundle = createSoyMsgBundle(Locale.ENGLISH); } if (soyMsgBundle == null) { return Optional.absent(); } if (isHotReloadModeOff()) { msgBundles.put(locale.get(), soyMsgBundle); } } return Optional.fromNullable(soyMsgBundle); } }
java
public Optional<SoyMsgBundle> resolve(final Optional<Locale> locale) throws IOException { if (!locale.isPresent()) { return Optional.absent(); } synchronized (msgBundles) { SoyMsgBundle soyMsgBundle = null; if (isHotReloadModeOff()) { soyMsgBundle = msgBundles.get(locale.get()); } if (soyMsgBundle == null) { soyMsgBundle = createSoyMsgBundle(locale.get()); if (soyMsgBundle == null) { soyMsgBundle = createSoyMsgBundle(new Locale(locale.get().getLanguage())); } if (soyMsgBundle == null && fallbackToEnglish) { soyMsgBundle = createSoyMsgBundle(Locale.ENGLISH); } if (soyMsgBundle == null) { return Optional.absent(); } if (isHotReloadModeOff()) { msgBundles.put(locale.get(), soyMsgBundle); } } return Optional.fromNullable(soyMsgBundle); } }
[ "public", "Optional", "<", "SoyMsgBundle", ">", "resolve", "(", "final", "Optional", "<", "Locale", ">", "locale", ")", "throws", "IOException", "{", "if", "(", "!", "locale", ".", "isPresent", "(", ")", ")", "{", "return", "Optional", ".", "absent", "(", ")", ";", "}", "synchronized", "(", "msgBundles", ")", "{", "SoyMsgBundle", "soyMsgBundle", "=", "null", ";", "if", "(", "isHotReloadModeOff", "(", ")", ")", "{", "soyMsgBundle", "=", "msgBundles", ".", "get", "(", "locale", ".", "get", "(", ")", ")", ";", "}", "if", "(", "soyMsgBundle", "==", "null", ")", "{", "soyMsgBundle", "=", "createSoyMsgBundle", "(", "locale", ".", "get", "(", ")", ")", ";", "if", "(", "soyMsgBundle", "==", "null", ")", "{", "soyMsgBundle", "=", "createSoyMsgBundle", "(", "new", "Locale", "(", "locale", ".", "get", "(", ")", ".", "getLanguage", "(", ")", ")", ")", ";", "}", "if", "(", "soyMsgBundle", "==", "null", "&&", "fallbackToEnglish", ")", "{", "soyMsgBundle", "=", "createSoyMsgBundle", "(", "Locale", ".", "ENGLISH", ")", ";", "}", "if", "(", "soyMsgBundle", "==", "null", ")", "{", "return", "Optional", ".", "absent", "(", ")", ";", "}", "if", "(", "isHotReloadModeOff", "(", ")", ")", "{", "msgBundles", ".", "put", "(", "locale", ".", "get", "(", ")", ",", "soyMsgBundle", ")", ";", "}", "}", "return", "Optional", ".", "fromNullable", "(", "soyMsgBundle", ")", ";", "}", "}" ]
Based on a provided locale return a SoyMsgBundle file. If a passed in locale object is "Optional.absent()", the implementation will return Optional.absent() as well @param locale - maybe locale @return maybe soy msg bundle
[ "Based", "on", "a", "provided", "locale", "return", "a", "SoyMsgBundle", "file", "." ]
a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1
https://github.com/matiwinnetou/spring-soy-view/blob/a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1/spring-soy-view/src/main/java/pl/matisoft/soy/bundle/DefaultSoyMsgBundleResolver.java#L62-L93
train
matiwinnetou/spring-soy-view
spring-soy-view/src/main/java/pl/matisoft/soy/bundle/DefaultSoyMsgBundleResolver.java
DefaultSoyMsgBundleResolver.mergeMsgBundles
private Optional<? extends SoyMsgBundle> mergeMsgBundles(final Locale locale, final List<SoyMsgBundle> soyMsgBundles) { if (soyMsgBundles.isEmpty()) { return Optional.absent(); } final List<SoyMsg> msgs = Lists.newArrayList(); for (final SoyMsgBundle smb : soyMsgBundles) { for (final Iterator<SoyMsg> it = smb.iterator(); it.hasNext();) { msgs.add(it.next()); } } return Optional.of(new SoyMsgBundleImpl(locale.toString(), msgs)); }
java
private Optional<? extends SoyMsgBundle> mergeMsgBundles(final Locale locale, final List<SoyMsgBundle> soyMsgBundles) { if (soyMsgBundles.isEmpty()) { return Optional.absent(); } final List<SoyMsg> msgs = Lists.newArrayList(); for (final SoyMsgBundle smb : soyMsgBundles) { for (final Iterator<SoyMsg> it = smb.iterator(); it.hasNext();) { msgs.add(it.next()); } } return Optional.of(new SoyMsgBundleImpl(locale.toString(), msgs)); }
[ "private", "Optional", "<", "?", "extends", "SoyMsgBundle", ">", "mergeMsgBundles", "(", "final", "Locale", "locale", ",", "final", "List", "<", "SoyMsgBundle", ">", "soyMsgBundles", ")", "{", "if", "(", "soyMsgBundles", ".", "isEmpty", "(", ")", ")", "{", "return", "Optional", ".", "absent", "(", ")", ";", "}", "final", "List", "<", "SoyMsg", ">", "msgs", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "final", "SoyMsgBundle", "smb", ":", "soyMsgBundles", ")", "{", "for", "(", "final", "Iterator", "<", "SoyMsg", ">", "it", "=", "smb", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "msgs", ".", "add", "(", "it", ".", "next", "(", ")", ")", ";", "}", "}", "return", "Optional", ".", "of", "(", "new", "SoyMsgBundleImpl", "(", "locale", ".", "toString", "(", ")", ",", "msgs", ")", ")", ";", "}" ]
Merge msg bundles together, creating new MsgBundle with merges msg bundles passed in as a method argument
[ "Merge", "msg", "bundles", "together", "creating", "new", "MsgBundle", "with", "merges", "msg", "bundles", "passed", "in", "as", "a", "method", "argument" ]
a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1
https://github.com/matiwinnetou/spring-soy-view/blob/a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1/spring-soy-view/src/main/java/pl/matisoft/soy/bundle/DefaultSoyMsgBundleResolver.java#L126-L139
train
matiwinnetou/spring-soy-view
spring-soy-view-ajax-compiler/src/main/java/pl/matisoft/soy/ajax/hash/MD5HashFileGenerator.java
MD5HashFileGenerator.hash
@Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); }
java
@Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); }
[ "@", "Override", "public", "Optional", "<", "String", ">", "hash", "(", "final", "Optional", "<", "URL", ">", "url", ")", "throws", "IOException", "{", "if", "(", "!", "url", ".", "isPresent", "(", ")", ")", "{", "return", "Optional", ".", "absent", "(", ")", ";", "}", "logger", ".", "debug", "(", "\"Calculating md5 hash, url:{}\"", ",", "url", ")", ";", "if", "(", "isHotReloadModeOff", "(", ")", ")", "{", "final", "String", "md5", "=", "cache", ".", "getIfPresent", "(", "url", ".", "get", "(", ")", ")", ";", "logger", ".", "debug", "(", "\"md5 hash:{}\"", ",", "md5", ")", ";", "if", "(", "md5", "!=", "null", ")", "{", "return", "Optional", ".", "of", "(", "md5", ")", ";", "}", "}", "final", "InputStream", "is", "=", "url", ".", "get", "(", ")", ".", "openStream", "(", ")", ";", "final", "String", "md5", "=", "getMD5Checksum", "(", "is", ")", ";", "if", "(", "isHotReloadModeOff", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"caching url:{} with hash:{}\"", ",", "url", ",", "md5", ")", ";", "cache", ".", "put", "(", "url", ".", "get", "(", ")", ",", "md5", ")", ";", "}", "return", "Optional", ".", "fromNullable", "(", "md5", ")", ";", "}" ]
Calculates a md5 hash for an url If a passed in url is absent then this method will return absent as well @param url - an url to a soy template file @return - md5 checksum of a template file @throws IOException - in a case there is an IO error calculating md5 checksum
[ "Calculates", "a", "md5", "hash", "for", "an", "url" ]
a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1
https://github.com/matiwinnetou/spring-soy-view/blob/a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1/spring-soy-view-ajax-compiler/src/main/java/pl/matisoft/soy/ajax/hash/MD5HashFileGenerator.java#L80-L106
train
Canadensys/canadensys-core
src/main/java/net/canadensys/utils/StringUtils.java
StringUtils.allUpperCase
public static String[] allUpperCase(String... strings){ String[] tmp = new String[strings.length]; for(int idx=0;idx<strings.length;idx++){ if(strings[idx] != null){ tmp[idx] = strings[idx].toUpperCase(); } } return tmp; }
java
public static String[] allUpperCase(String... strings){ String[] tmp = new String[strings.length]; for(int idx=0;idx<strings.length;idx++){ if(strings[idx] != null){ tmp[idx] = strings[idx].toUpperCase(); } } return tmp; }
[ "public", "static", "String", "[", "]", "allUpperCase", "(", "String", "...", "strings", ")", "{", "String", "[", "]", "tmp", "=", "new", "String", "[", "strings", ".", "length", "]", ";", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "strings", ".", "length", ";", "idx", "++", ")", "{", "if", "(", "strings", "[", "idx", "]", "!=", "null", ")", "{", "tmp", "[", "idx", "]", "=", "strings", "[", "idx", "]", ".", "toUpperCase", "(", ")", ";", "}", "}", "return", "tmp", ";", "}" ]
Make all elements of a String array upper case. @param strings string array, may contain null item but can't be null @return array containing all provided elements upper case
[ "Make", "all", "elements", "of", "a", "String", "array", "upper", "case", "." ]
5e13569f7c0f4cdc7080da72643ff61123ad76fd
https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/StringUtils.java#L20-L28
train
Canadensys/canadensys-core
src/main/java/net/canadensys/utils/StringUtils.java
StringUtils.allLowerCase
public static String[] allLowerCase(String... strings){ String[] tmp = new String[strings.length]; for(int idx=0;idx<strings.length;idx++){ if(strings[idx] != null){ tmp[idx] = strings[idx].toLowerCase(); } } return tmp; }
java
public static String[] allLowerCase(String... strings){ String[] tmp = new String[strings.length]; for(int idx=0;idx<strings.length;idx++){ if(strings[idx] != null){ tmp[idx] = strings[idx].toLowerCase(); } } return tmp; }
[ "public", "static", "String", "[", "]", "allLowerCase", "(", "String", "...", "strings", ")", "{", "String", "[", "]", "tmp", "=", "new", "String", "[", "strings", ".", "length", "]", ";", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "strings", ".", "length", ";", "idx", "++", ")", "{", "if", "(", "strings", "[", "idx", "]", "!=", "null", ")", "{", "tmp", "[", "idx", "]", "=", "strings", "[", "idx", "]", ".", "toLowerCase", "(", ")", ";", "}", "}", "return", "tmp", ";", "}" ]
Make all elements of a String array lower case. @param strings string array, may contain null item but can't be null @return array containing all provided elements lower case
[ "Make", "all", "elements", "of", "a", "String", "array", "lower", "case", "." ]
5e13569f7c0f4cdc7080da72643ff61123ad76fd
https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/StringUtils.java#L35-L43
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/signature/ClassTypeSignature.java
ClassTypeSignature.getTypeErasureSignature
public FullTypeSignature getTypeErasureSignature() { if (typeErasureSignature == null) { typeErasureSignature = new ClassTypeSignature(binaryName, new TypeArgSignature[0], ownerTypeSignature == null ? null : (ClassTypeSignature) ownerTypeSignature .getTypeErasureSignature()); } return typeErasureSignature; }
java
public FullTypeSignature getTypeErasureSignature() { if (typeErasureSignature == null) { typeErasureSignature = new ClassTypeSignature(binaryName, new TypeArgSignature[0], ownerTypeSignature == null ? null : (ClassTypeSignature) ownerTypeSignature .getTypeErasureSignature()); } return typeErasureSignature; }
[ "public", "FullTypeSignature", "getTypeErasureSignature", "(", ")", "{", "if", "(", "typeErasureSignature", "==", "null", ")", "{", "typeErasureSignature", "=", "new", "ClassTypeSignature", "(", "binaryName", ",", "new", "TypeArgSignature", "[", "0", "]", ",", "ownerTypeSignature", "==", "null", "?", "null", ":", "(", "ClassTypeSignature", ")", "ownerTypeSignature", ".", "getTypeErasureSignature", "(", ")", ")", ";", "}", "return", "typeErasureSignature", ";", "}" ]
get the type erasure signature
[ "get", "the", "type", "erasure", "signature" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/ClassTypeSignature.java#L118-L126
train
httpcache4j/httpcache4j
httpcache4j-api/src/main/java/org/codehaus/httpcache4j/MIMEType.java
MIMEType.addParameter
public MIMEType addParameter(String name, String value) { Map<String, String> copy = new LinkedHashMap<>(this.parameters); copy.put(name, value); return new MIMEType(type, subType, copy); }
java
public MIMEType addParameter(String name, String value) { Map<String, String> copy = new LinkedHashMap<>(this.parameters); copy.put(name, value); return new MIMEType(type, subType, copy); }
[ "public", "MIMEType", "addParameter", "(", "String", "name", ",", "String", "value", ")", "{", "Map", "<", "String", ",", "String", ">", "copy", "=", "new", "LinkedHashMap", "<>", "(", "this", ".", "parameters", ")", ";", "copy", ".", "put", "(", "name", ",", "value", ")", ";", "return", "new", "MIMEType", "(", "type", ",", "subType", ",", "copy", ")", ";", "}" ]
Adds a parameter to the MIMEType. @param name name of parameter @param value value of parameter @return returns a new instance with the parameter set
[ "Adds", "a", "parameter", "to", "the", "MIMEType", "." ]
9c07ebd63cd104a99eb9e771f760f14efa4fe0f6
https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/MIMEType.java#L54-L58
train
matiwinnetou/spring-soy-view
spring-soy-view/src/main/java/pl/matisoft/soy/DefaultContentNegotiator.java
DefaultContentNegotiator.contentTypes
@Override public List<String> contentTypes() { List<String> contentTypes = null; final HttpServletRequest request = getHttpRequest(); if (favorParameterOverAcceptHeader) { contentTypes = getFavoredParameterValueAsList(request); } else { contentTypes = getAcceptHeaderValues(request); } if (isEmpty(contentTypes)) { logger.debug("Setting content types to default: {}.", DEFAULT_SUPPORTED_CONTENT_TYPES); contentTypes = DEFAULT_SUPPORTED_CONTENT_TYPES; } return unmodifiableList(contentTypes); }
java
@Override public List<String> contentTypes() { List<String> contentTypes = null; final HttpServletRequest request = getHttpRequest(); if (favorParameterOverAcceptHeader) { contentTypes = getFavoredParameterValueAsList(request); } else { contentTypes = getAcceptHeaderValues(request); } if (isEmpty(contentTypes)) { logger.debug("Setting content types to default: {}.", DEFAULT_SUPPORTED_CONTENT_TYPES); contentTypes = DEFAULT_SUPPORTED_CONTENT_TYPES; } return unmodifiableList(contentTypes); }
[ "@", "Override", "public", "List", "<", "String", ">", "contentTypes", "(", ")", "{", "List", "<", "String", ">", "contentTypes", "=", "null", ";", "final", "HttpServletRequest", "request", "=", "getHttpRequest", "(", ")", ";", "if", "(", "favorParameterOverAcceptHeader", ")", "{", "contentTypes", "=", "getFavoredParameterValueAsList", "(", "request", ")", ";", "}", "else", "{", "contentTypes", "=", "getAcceptHeaderValues", "(", "request", ")", ";", "}", "if", "(", "isEmpty", "(", "contentTypes", ")", ")", "{", "logger", ".", "debug", "(", "\"Setting content types to default: {}.\"", ",", "DEFAULT_SUPPORTED_CONTENT_TYPES", ")", ";", "contentTypes", "=", "DEFAULT_SUPPORTED_CONTENT_TYPES", ";", "}", "return", "unmodifiableList", "(", "contentTypes", ")", ";", "}" ]
Returns requested content types or default content type if none found. @return Requested content types or default content type if none found.
[ "Returns", "requested", "content", "types", "or", "default", "content", "type", "if", "none", "found", "." ]
a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1
https://github.com/matiwinnetou/spring-soy-view/blob/a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1/spring-soy-view/src/main/java/pl/matisoft/soy/DefaultContentNegotiator.java#L96-L114
train
httpcache4j/httpcache4j
httpcache4j-api/src/main/java/org/codehaus/httpcache4j/HTTPRequest.java
HTTPRequest.getAllHeaders
public Headers getAllHeaders() { Headers requestHeaders = getHeaders(); requestHeaders = hasPayload() ? requestHeaders.withContentType(getPayload().get().getMimeType()) : requestHeaders; //We don't want to add headers more than once. return requestHeaders; }
java
public Headers getAllHeaders() { Headers requestHeaders = getHeaders(); requestHeaders = hasPayload() ? requestHeaders.withContentType(getPayload().get().getMimeType()) : requestHeaders; //We don't want to add headers more than once. return requestHeaders; }
[ "public", "Headers", "getAllHeaders", "(", ")", "{", "Headers", "requestHeaders", "=", "getHeaders", "(", ")", ";", "requestHeaders", "=", "hasPayload", "(", ")", "?", "requestHeaders", ".", "withContentType", "(", "getPayload", "(", ")", ".", "get", "(", ")", ".", "getMimeType", "(", ")", ")", ":", "requestHeaders", ";", "//We don't want to add headers more than once.", "return", "requestHeaders", ";", "}" ]
Returns all headers with the headers from the Payload @return All the headers
[ "Returns", "all", "headers", "with", "the", "headers", "from", "the", "Payload" ]
9c07ebd63cd104a99eb9e771f760f14efa4fe0f6
https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/HTTPRequest.java#L102-L107
train
mgormley/optimize
src/main/java/edu/jhu/hlt/optimize/function/DifferentiableFunctionOpts.java
DifferentiableFunctionOpts.getRegularizedOptimizer
public static Optimizer<DifferentiableFunction> getRegularizedOptimizer(final Optimizer<DifferentiableFunction> opt, final double l1Lambda, final double l2Lambda) { if (l1Lambda == 0 && l2Lambda == 0) { return opt; } return new Optimizer<DifferentiableFunction>() { @Override public boolean minimize(DifferentiableFunction objective, IntDoubleVector point) { DifferentiableFunction fn = getRegularizedFn(objective, false, l1Lambda, l2Lambda); return opt.minimize(fn, point); } }; }
java
public static Optimizer<DifferentiableFunction> getRegularizedOptimizer(final Optimizer<DifferentiableFunction> opt, final double l1Lambda, final double l2Lambda) { if (l1Lambda == 0 && l2Lambda == 0) { return opt; } return new Optimizer<DifferentiableFunction>() { @Override public boolean minimize(DifferentiableFunction objective, IntDoubleVector point) { DifferentiableFunction fn = getRegularizedFn(objective, false, l1Lambda, l2Lambda); return opt.minimize(fn, point); } }; }
[ "public", "static", "Optimizer", "<", "DifferentiableFunction", ">", "getRegularizedOptimizer", "(", "final", "Optimizer", "<", "DifferentiableFunction", ">", "opt", ",", "final", "double", "l1Lambda", ",", "final", "double", "l2Lambda", ")", "{", "if", "(", "l1Lambda", "==", "0", "&&", "l2Lambda", "==", "0", ")", "{", "return", "opt", ";", "}", "return", "new", "Optimizer", "<", "DifferentiableFunction", ">", "(", ")", "{", "@", "Override", "public", "boolean", "minimize", "(", "DifferentiableFunction", "objective", ",", "IntDoubleVector", "point", ")", "{", "DifferentiableFunction", "fn", "=", "getRegularizedFn", "(", "objective", ",", "false", ",", "l1Lambda", ",", "l2Lambda", ")", ";", "return", "opt", ".", "minimize", "(", "fn", ",", "point", ")", ";", "}", "}", ";", "}" ]
Converts a standard optimizer to one which the given amount of l1 or l2 regularization.
[ "Converts", "a", "standard", "optimizer", "to", "one", "which", "the", "given", "amount", "of", "l1", "or", "l2", "regularization", "." ]
3d1b93260b99febb8a5ecd9e8543c223e151a8d3
https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/DifferentiableFunctionOpts.java#L165-L179
train
Canadensys/canadensys-core
src/main/java/net/canadensys/lang/RomanNumeral.java
RomanNumeral.toRomanNumeral
public String toRomanNumeral() { if (this.romanString == null) { this.romanString = ""; int remainder = this.value; for (int i = 0; i < BASIC_VALUES.length; i++) { while (remainder >= BASIC_VALUES[i]) { this.romanString += BASIC_ROMAN_NUMERALS[i]; remainder -= BASIC_VALUES[i]; } } } return this.romanString; }
java
public String toRomanNumeral() { if (this.romanString == null) { this.romanString = ""; int remainder = this.value; for (int i = 0; i < BASIC_VALUES.length; i++) { while (remainder >= BASIC_VALUES[i]) { this.romanString += BASIC_ROMAN_NUMERALS[i]; remainder -= BASIC_VALUES[i]; } } } return this.romanString; }
[ "public", "String", "toRomanNumeral", "(", ")", "{", "if", "(", "this", ".", "romanString", "==", "null", ")", "{", "this", ".", "romanString", "=", "\"\"", ";", "int", "remainder", "=", "this", ".", "value", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "BASIC_VALUES", ".", "length", ";", "i", "++", ")", "{", "while", "(", "remainder", ">=", "BASIC_VALUES", "[", "i", "]", ")", "{", "this", ".", "romanString", "+=", "BASIC_ROMAN_NUMERALS", "[", "i", "]", ";", "remainder", "-=", "BASIC_VALUES", "[", "i", "]", ";", "}", "}", "}", "return", "this", ".", "romanString", ";", "}" ]
Get the Roman Numeral of the current value @return
[ "Get", "the", "Roman", "Numeral", "of", "the", "current", "value" ]
5e13569f7c0f4cdc7080da72643ff61123ad76fd
https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/lang/RomanNumeral.java#L82-L94
train
mgormley/optimize
src/main/java/edu/jhu/hlt/optimize/AdaGradSchedule.java
AdaGradSchedule.takeNoteOfGradient
public void takeNoteOfGradient(IntDoubleVector gradient) { gradient.iterate(new FnIntDoubleToVoid() { @Override public void call(int index, double value) { gradSumSquares[index] += value * value; assert !Double.isNaN(gradSumSquares[index]); } }); }
java
public void takeNoteOfGradient(IntDoubleVector gradient) { gradient.iterate(new FnIntDoubleToVoid() { @Override public void call(int index, double value) { gradSumSquares[index] += value * value; assert !Double.isNaN(gradSumSquares[index]); } }); }
[ "public", "void", "takeNoteOfGradient", "(", "IntDoubleVector", "gradient", ")", "{", "gradient", ".", "iterate", "(", "new", "FnIntDoubleToVoid", "(", ")", "{", "@", "Override", "public", "void", "call", "(", "int", "index", ",", "double", "value", ")", "{", "gradSumSquares", "[", "index", "]", "+=", "value", "*", "value", ";", "assert", "!", "Double", ".", "isNaN", "(", "gradSumSquares", "[", "index", "]", ")", ";", "}", "}", ")", ";", "}" ]
A tie-in for subclasses such as AdaGrad.
[ "A", "tie", "-", "in", "for", "subclasses", "such", "as", "AdaGrad", "." ]
3d1b93260b99febb8a5ecd9e8543c223e151a8d3
https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/AdaGradSchedule.java#L58-L66
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java
JavaTypeToTypeSignature.getArrayTypeSignature
private ArrayTypeSignature getArrayTypeSignature( GenericArrayType genericArrayType) { FullTypeSignature componentTypeSignature = getFullTypeSignature(genericArrayType .getGenericComponentType()); ArrayTypeSignature arrayTypeSignature = new ArrayTypeSignature( componentTypeSignature); return arrayTypeSignature; }
java
private ArrayTypeSignature getArrayTypeSignature( GenericArrayType genericArrayType) { FullTypeSignature componentTypeSignature = getFullTypeSignature(genericArrayType .getGenericComponentType()); ArrayTypeSignature arrayTypeSignature = new ArrayTypeSignature( componentTypeSignature); return arrayTypeSignature; }
[ "private", "ArrayTypeSignature", "getArrayTypeSignature", "(", "GenericArrayType", "genericArrayType", ")", "{", "FullTypeSignature", "componentTypeSignature", "=", "getFullTypeSignature", "(", "genericArrayType", ".", "getGenericComponentType", "(", ")", ")", ";", "ArrayTypeSignature", "arrayTypeSignature", "=", "new", "ArrayTypeSignature", "(", "componentTypeSignature", ")", ";", "return", "arrayTypeSignature", ";", "}" ]
get the ArrayTypeSignature corresponding to given generic array type @param genericArrayType @return
[ "get", "the", "ArrayTypeSignature", "corresponding", "to", "given", "generic", "array", "type" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java#L45-L52
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java
JavaTypeToTypeSignature.getClassTypeSignature
private ClassTypeSignature getClassTypeSignature( ParameterizedType parameterizedType) { Class<?> rawType = (Class<?>) parameterizedType.getRawType(); Type[] typeArguments = parameterizedType.getActualTypeArguments(); TypeArgSignature[] typeArgSignatures = new TypeArgSignature[typeArguments.length]; for (int i = 0; i < typeArguments.length; i++) { typeArgSignatures[i] = getTypeArgSignature(typeArguments[i]); } String binaryName = rawType.isMemberClass() ? rawType.getSimpleName() : rawType.getName(); ClassTypeSignature ownerTypeSignature = parameterizedType .getOwnerType() == null ? null : (ClassTypeSignature) getFullTypeSignature(parameterizedType .getOwnerType()); ClassTypeSignature classTypeSignature = new ClassTypeSignature( binaryName, typeArgSignatures, ownerTypeSignature); return classTypeSignature; }
java
private ClassTypeSignature getClassTypeSignature( ParameterizedType parameterizedType) { Class<?> rawType = (Class<?>) parameterizedType.getRawType(); Type[] typeArguments = parameterizedType.getActualTypeArguments(); TypeArgSignature[] typeArgSignatures = new TypeArgSignature[typeArguments.length]; for (int i = 0; i < typeArguments.length; i++) { typeArgSignatures[i] = getTypeArgSignature(typeArguments[i]); } String binaryName = rawType.isMemberClass() ? rawType.getSimpleName() : rawType.getName(); ClassTypeSignature ownerTypeSignature = parameterizedType .getOwnerType() == null ? null : (ClassTypeSignature) getFullTypeSignature(parameterizedType .getOwnerType()); ClassTypeSignature classTypeSignature = new ClassTypeSignature( binaryName, typeArgSignatures, ownerTypeSignature); return classTypeSignature; }
[ "private", "ClassTypeSignature", "getClassTypeSignature", "(", "ParameterizedType", "parameterizedType", ")", "{", "Class", "<", "?", ">", "rawType", "=", "(", "Class", "<", "?", ">", ")", "parameterizedType", ".", "getRawType", "(", ")", ";", "Type", "[", "]", "typeArguments", "=", "parameterizedType", ".", "getActualTypeArguments", "(", ")", ";", "TypeArgSignature", "[", "]", "typeArgSignatures", "=", "new", "TypeArgSignature", "[", "typeArguments", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "typeArguments", ".", "length", ";", "i", "++", ")", "{", "typeArgSignatures", "[", "i", "]", "=", "getTypeArgSignature", "(", "typeArguments", "[", "i", "]", ")", ";", "}", "String", "binaryName", "=", "rawType", ".", "isMemberClass", "(", ")", "?", "rawType", ".", "getSimpleName", "(", ")", ":", "rawType", ".", "getName", "(", ")", ";", "ClassTypeSignature", "ownerTypeSignature", "=", "parameterizedType", ".", "getOwnerType", "(", ")", "==", "null", "?", "null", ":", "(", "ClassTypeSignature", ")", "getFullTypeSignature", "(", "parameterizedType", ".", "getOwnerType", "(", ")", ")", ";", "ClassTypeSignature", "classTypeSignature", "=", "new", "ClassTypeSignature", "(", "binaryName", ",", "typeArgSignatures", ",", "ownerTypeSignature", ")", ";", "return", "classTypeSignature", ";", "}" ]
get the ClassTypeSignature corresponding to given parameterized type @param parameterizedType @return
[ "get", "the", "ClassTypeSignature", "corresponding", "to", "given", "parameterized", "type" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java#L60-L78
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java
JavaTypeToTypeSignature.getTypeSignature
private FullTypeSignature getTypeSignature(Class<?> clazz) { StringBuilder sb = new StringBuilder(); if (clazz.isArray()) { sb.append(clazz.getName()); } else if (clazz.isPrimitive()) { sb.append(primitiveTypesMap.get(clazz).toString()); } else { sb.append('L').append(clazz.getName()).append(';'); } return TypeSignatureFactory.getTypeSignature(sb.toString(), false); }
java
private FullTypeSignature getTypeSignature(Class<?> clazz) { StringBuilder sb = new StringBuilder(); if (clazz.isArray()) { sb.append(clazz.getName()); } else if (clazz.isPrimitive()) { sb.append(primitiveTypesMap.get(clazz).toString()); } else { sb.append('L').append(clazz.getName()).append(';'); } return TypeSignatureFactory.getTypeSignature(sb.toString(), false); }
[ "private", "FullTypeSignature", "getTypeSignature", "(", "Class", "<", "?", ">", "clazz", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "clazz", ".", "isArray", "(", ")", ")", "{", "sb", ".", "append", "(", "clazz", ".", "getName", "(", ")", ")", ";", "}", "else", "if", "(", "clazz", ".", "isPrimitive", "(", ")", ")", "{", "sb", ".", "append", "(", "primitiveTypesMap", ".", "get", "(", "clazz", ")", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "'", "'", ")", ".", "append", "(", "clazz", ".", "getName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "return", "TypeSignatureFactory", ".", "getTypeSignature", "(", "sb", ".", "toString", "(", ")", ",", "false", ")", ";", "}" ]
get the type signature corresponding to given class @param clazz @return
[ "get", "the", "type", "signature", "corresponding", "to", "given", "class" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java#L126-L137
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java
JavaTypeToTypeSignature.getTypeArgSignature
private TypeArgSignature getTypeArgSignature(Type type) { if (type instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type; Type lowerBound = wildcardType.getLowerBounds().length == 0 ? null : wildcardType.getLowerBounds()[0]; Type upperBound = wildcardType.getUpperBounds().length == 0 ? null : wildcardType.getUpperBounds()[0]; if (lowerBound == null && Object.class.equals(upperBound)) { return new TypeArgSignature( TypeArgSignature.UNBOUNDED_WILDCARD, (FieldTypeSignature) getFullTypeSignature(upperBound)); } else if (lowerBound == null && upperBound != null) { return new TypeArgSignature( TypeArgSignature.UPPERBOUND_WILDCARD, (FieldTypeSignature) getFullTypeSignature(upperBound)); } else if (lowerBound != null) { return new TypeArgSignature( TypeArgSignature.LOWERBOUND_WILDCARD, (FieldTypeSignature) getFullTypeSignature(lowerBound)); } else { throw new RuntimeException("Invalid type"); } } else { return new TypeArgSignature(TypeArgSignature.NO_WILDCARD, (FieldTypeSignature) getFullTypeSignature(type)); } }
java
private TypeArgSignature getTypeArgSignature(Type type) { if (type instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type; Type lowerBound = wildcardType.getLowerBounds().length == 0 ? null : wildcardType.getLowerBounds()[0]; Type upperBound = wildcardType.getUpperBounds().length == 0 ? null : wildcardType.getUpperBounds()[0]; if (lowerBound == null && Object.class.equals(upperBound)) { return new TypeArgSignature( TypeArgSignature.UNBOUNDED_WILDCARD, (FieldTypeSignature) getFullTypeSignature(upperBound)); } else if (lowerBound == null && upperBound != null) { return new TypeArgSignature( TypeArgSignature.UPPERBOUND_WILDCARD, (FieldTypeSignature) getFullTypeSignature(upperBound)); } else if (lowerBound != null) { return new TypeArgSignature( TypeArgSignature.LOWERBOUND_WILDCARD, (FieldTypeSignature) getFullTypeSignature(lowerBound)); } else { throw new RuntimeException("Invalid type"); } } else { return new TypeArgSignature(TypeArgSignature.NO_WILDCARD, (FieldTypeSignature) getFullTypeSignature(type)); } }
[ "private", "TypeArgSignature", "getTypeArgSignature", "(", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "WildcardType", ")", "{", "WildcardType", "wildcardType", "=", "(", "WildcardType", ")", "type", ";", "Type", "lowerBound", "=", "wildcardType", ".", "getLowerBounds", "(", ")", ".", "length", "==", "0", "?", "null", ":", "wildcardType", ".", "getLowerBounds", "(", ")", "[", "0", "]", ";", "Type", "upperBound", "=", "wildcardType", ".", "getUpperBounds", "(", ")", ".", "length", "==", "0", "?", "null", ":", "wildcardType", ".", "getUpperBounds", "(", ")", "[", "0", "]", ";", "if", "(", "lowerBound", "==", "null", "&&", "Object", ".", "class", ".", "equals", "(", "upperBound", ")", ")", "{", "return", "new", "TypeArgSignature", "(", "TypeArgSignature", ".", "UNBOUNDED_WILDCARD", ",", "(", "FieldTypeSignature", ")", "getFullTypeSignature", "(", "upperBound", ")", ")", ";", "}", "else", "if", "(", "lowerBound", "==", "null", "&&", "upperBound", "!=", "null", ")", "{", "return", "new", "TypeArgSignature", "(", "TypeArgSignature", ".", "UPPERBOUND_WILDCARD", ",", "(", "FieldTypeSignature", ")", "getFullTypeSignature", "(", "upperBound", ")", ")", ";", "}", "else", "if", "(", "lowerBound", "!=", "null", ")", "{", "return", "new", "TypeArgSignature", "(", "TypeArgSignature", ".", "LOWERBOUND_WILDCARD", ",", "(", "FieldTypeSignature", ")", "getFullTypeSignature", "(", "lowerBound", ")", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Invalid type\"", ")", ";", "}", "}", "else", "{", "return", "new", "TypeArgSignature", "(", "TypeArgSignature", ".", "NO_WILDCARD", ",", "(", "FieldTypeSignature", ")", "getFullTypeSignature", "(", "type", ")", ")", ";", "}", "}" ]
get the TypeArgSignature corresponding to given type @param type @return
[ "get", "the", "TypeArgSignature", "corresponding", "to", "given", "type" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/JavaTypeToTypeSignature.java#L145-L172
train
Canadensys/canadensys-core
src/main/java/net/canadensys/utils/ZipUtils.java
ZipUtils.zipFolder
public static boolean zipFolder(File folder, String fileName){ boolean success = false; if(!folder.isDirectory()){ return false; } if(fileName == null){ fileName = folder.getAbsolutePath()+ZIP_EXT; } ZipArchiveOutputStream zipOutput = null; try { zipOutput = new ZipArchiveOutputStream(new File(fileName)); success = addFolderContentToZip(folder,zipOutput,""); zipOutput.close(); } catch (IOException e) { e.printStackTrace(); return false; } finally{ try { if(zipOutput != null){ zipOutput.close(); } } catch (IOException e) {} } return success; }
java
public static boolean zipFolder(File folder, String fileName){ boolean success = false; if(!folder.isDirectory()){ return false; } if(fileName == null){ fileName = folder.getAbsolutePath()+ZIP_EXT; } ZipArchiveOutputStream zipOutput = null; try { zipOutput = new ZipArchiveOutputStream(new File(fileName)); success = addFolderContentToZip(folder,zipOutput,""); zipOutput.close(); } catch (IOException e) { e.printStackTrace(); return false; } finally{ try { if(zipOutput != null){ zipOutput.close(); } } catch (IOException e) {} } return success; }
[ "public", "static", "boolean", "zipFolder", "(", "File", "folder", ",", "String", "fileName", ")", "{", "boolean", "success", "=", "false", ";", "if", "(", "!", "folder", ".", "isDirectory", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "fileName", "==", "null", ")", "{", "fileName", "=", "folder", ".", "getAbsolutePath", "(", ")", "+", "ZIP_EXT", ";", "}", "ZipArchiveOutputStream", "zipOutput", "=", "null", ";", "try", "{", "zipOutput", "=", "new", "ZipArchiveOutputStream", "(", "new", "File", "(", "fileName", ")", ")", ";", "success", "=", "addFolderContentToZip", "(", "folder", ",", "zipOutput", ",", "\"\"", ")", ";", "zipOutput", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "finally", "{", "try", "{", "if", "(", "zipOutput", "!=", "null", ")", "{", "zipOutput", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "return", "success", ";", "}" ]
Utility function to zip the content of an entire folder, but not the folder itself. @param folder @param fileName optional @return success or not
[ "Utility", "function", "to", "zip", "the", "content", "of", "an", "entire", "folder", "but", "not", "the", "folder", "itself", "." ]
5e13569f7c0f4cdc7080da72643ff61123ad76fd
https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/ZipUtils.java#L34-L64
train
Canadensys/canadensys-core
src/main/java/net/canadensys/utils/ZipUtils.java
ZipUtils.unzipFileOrFolder
public static boolean unzipFileOrFolder(File zipFile, String unzippedFolder){ InputStream is; ArchiveInputStream in = null; OutputStream out = null; if(!zipFile.isFile()){ return false; } if(unzippedFolder == null){ unzippedFolder = FilenameUtils.removeExtension(zipFile.getAbsolutePath()); } try { is = new FileInputStream(zipFile); new File(unzippedFolder).mkdir(); in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is); ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry(); while(entry != null){ if(entry.isDirectory()){ new File(unzippedFolder,entry.getName()).mkdir(); } else{ out = new FileOutputStream(new File(unzippedFolder, entry.getName())); IOUtils.copy(in, out); out.close(); out = null; } entry = (ZipArchiveEntry)in.getNextEntry(); } } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (ArchiveException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } finally{ if(out != null){ try { out.close(); } catch (IOException e) {} } if(in != null){ try { in.close(); } catch (IOException e) {} } } return true; }
java
public static boolean unzipFileOrFolder(File zipFile, String unzippedFolder){ InputStream is; ArchiveInputStream in = null; OutputStream out = null; if(!zipFile.isFile()){ return false; } if(unzippedFolder == null){ unzippedFolder = FilenameUtils.removeExtension(zipFile.getAbsolutePath()); } try { is = new FileInputStream(zipFile); new File(unzippedFolder).mkdir(); in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is); ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry(); while(entry != null){ if(entry.isDirectory()){ new File(unzippedFolder,entry.getName()).mkdir(); } else{ out = new FileOutputStream(new File(unzippedFolder, entry.getName())); IOUtils.copy(in, out); out.close(); out = null; } entry = (ZipArchiveEntry)in.getNextEntry(); } } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (ArchiveException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } finally{ if(out != null){ try { out.close(); } catch (IOException e) {} } if(in != null){ try { in.close(); } catch (IOException e) {} } } return true; }
[ "public", "static", "boolean", "unzipFileOrFolder", "(", "File", "zipFile", ",", "String", "unzippedFolder", ")", "{", "InputStream", "is", ";", "ArchiveInputStream", "in", "=", "null", ";", "OutputStream", "out", "=", "null", ";", "if", "(", "!", "zipFile", ".", "isFile", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "unzippedFolder", "==", "null", ")", "{", "unzippedFolder", "=", "FilenameUtils", ".", "removeExtension", "(", "zipFile", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "try", "{", "is", "=", "new", "FileInputStream", "(", "zipFile", ")", ";", "new", "File", "(", "unzippedFolder", ")", ".", "mkdir", "(", ")", ";", "in", "=", "new", "ArchiveStreamFactory", "(", ")", ".", "createArchiveInputStream", "(", "ArchiveStreamFactory", ".", "ZIP", ",", "is", ")", ";", "ZipArchiveEntry", "entry", "=", "(", "ZipArchiveEntry", ")", "in", ".", "getNextEntry", "(", ")", ";", "while", "(", "entry", "!=", "null", ")", "{", "if", "(", "entry", ".", "isDirectory", "(", ")", ")", "{", "new", "File", "(", "unzippedFolder", ",", "entry", ".", "getName", "(", ")", ")", ".", "mkdir", "(", ")", ";", "}", "else", "{", "out", "=", "new", "FileOutputStream", "(", "new", "File", "(", "unzippedFolder", ",", "entry", ".", "getName", "(", ")", ")", ")", ";", "IOUtils", ".", "copy", "(", "in", ",", "out", ")", ";", "out", ".", "close", "(", ")", ";", "out", "=", "null", ";", "}", "entry", "=", "(", "ZipArchiveEntry", ")", "in", ".", "getNextEntry", "(", ")", ";", "}", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "catch", "(", "ArchiveException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "finally", "{", "if", "(", "out", "!=", "null", ")", "{", "try", "{", "out", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "if", "(", "in", "!=", "null", ")", "{", "try", "{", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "return", "true", ";", "}" ]
Unzip a file or a folder @param zipFile @param unzippedFolder optional, if null the file/folder will be extracted in the same folder as zipFile @return
[ "Unzip", "a", "file", "or", "a", "folder" ]
5e13569f7c0f4cdc7080da72643ff61123ad76fd
https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/ZipUtils.java#L117-L171
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplShared.java
UTCTimeBoxImplShared.formatUsingFormat
protected static final String formatUsingFormat(Long value, DateTimeFormat fmt) { if (value == null) { return ""; } else { // midnight GMT Date date = new Date(0); // offset by timezone and value date.setTime(UTCDateBox.timezoneOffsetMillis(date) + value.longValue()); // format it return fmt.format(date); } }
java
protected static final String formatUsingFormat(Long value, DateTimeFormat fmt) { if (value == null) { return ""; } else { // midnight GMT Date date = new Date(0); // offset by timezone and value date.setTime(UTCDateBox.timezoneOffsetMillis(date) + value.longValue()); // format it return fmt.format(date); } }
[ "protected", "static", "final", "String", "formatUsingFormat", "(", "Long", "value", ",", "DateTimeFormat", "fmt", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "\"\"", ";", "}", "else", "{", "// midnight GMT", "Date", "date", "=", "new", "Date", "(", "0", ")", ";", "// offset by timezone and value", "date", ".", "setTime", "(", "UTCDateBox", ".", "timezoneOffsetMillis", "(", "date", ")", "+", "value", ".", "longValue", "(", ")", ")", ";", "// format it", "return", "fmt", ".", "format", "(", "date", ")", ";", "}", "}" ]
Formats the value provided with the specified DateTimeFormat
[ "Formats", "the", "value", "provided", "with", "the", "specified", "DateTimeFormat" ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplShared.java#L111-L123
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplShared.java
UTCTimeBoxImplShared.parseUsingFallbacksWithColon
protected static final Long parseUsingFallbacksWithColon(String text, DateTimeFormat timeFormat) { if (text.indexOf(':') == -1) { text = text.replace(" ", ""); int numdigits = 0; int lastdigit = 0; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (Character.isDigit(c)) { numdigits++; lastdigit = i; } } if (numdigits == 1 || numdigits == 2) { // insert :00 int colon = lastdigit + 1; text = text.substring(0, colon) + ":00" + text.substring(colon); } else if (numdigits > 2) { // insert : int colon = lastdigit - 1; text = text.substring(0, colon) + ":" + text.substring(colon); } return parseUsingFallbacks(text, timeFormat); } else { return null; } }
java
protected static final Long parseUsingFallbacksWithColon(String text, DateTimeFormat timeFormat) { if (text.indexOf(':') == -1) { text = text.replace(" ", ""); int numdigits = 0; int lastdigit = 0; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (Character.isDigit(c)) { numdigits++; lastdigit = i; } } if (numdigits == 1 || numdigits == 2) { // insert :00 int colon = lastdigit + 1; text = text.substring(0, colon) + ":00" + text.substring(colon); } else if (numdigits > 2) { // insert : int colon = lastdigit - 1; text = text.substring(0, colon) + ":" + text.substring(colon); } return parseUsingFallbacks(text, timeFormat); } else { return null; } }
[ "protected", "static", "final", "Long", "parseUsingFallbacksWithColon", "(", "String", "text", ",", "DateTimeFormat", "timeFormat", ")", "{", "if", "(", "text", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "text", "=", "text", ".", "replace", "(", "\" \"", ",", "\"\"", ")", ";", "int", "numdigits", "=", "0", ";", "int", "lastdigit", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "text", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "text", ".", "charAt", "(", "i", ")", ";", "if", "(", "Character", ".", "isDigit", "(", "c", ")", ")", "{", "numdigits", "++", ";", "lastdigit", "=", "i", ";", "}", "}", "if", "(", "numdigits", "==", "1", "||", "numdigits", "==", "2", ")", "{", "// insert :00", "int", "colon", "=", "lastdigit", "+", "1", ";", "text", "=", "text", ".", "substring", "(", "0", ",", "colon", ")", "+", "\":00\"", "+", "text", ".", "substring", "(", "colon", ")", ";", "}", "else", "if", "(", "numdigits", ">", "2", ")", "{", "// insert :", "int", "colon", "=", "lastdigit", "-", "1", ";", "text", "=", "text", ".", "substring", "(", "0", ",", "colon", ")", "+", "\":\"", "+", "text", ".", "substring", "(", "colon", ")", ";", "}", "return", "parseUsingFallbacks", "(", "text", ",", "timeFormat", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Attempts to insert a colon so that a value without a colon can be parsed.
[ "Attempts", "to", "insert", "a", "colon", "so", "that", "a", "value", "without", "a", "colon", "can", "be", "parsed", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplShared.java#L129-L156
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeUtils.java
TypeUtils.getRawType
public static Class<?> getRawType(Type type) { if (type instanceof Class) { return (Class<?>) type; } else if (type instanceof ParameterizedType) { ParameterizedType actualType = (ParameterizedType) type; return getRawType(actualType.getRawType()); } else if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; Object rawArrayType = Array.newInstance(getRawType(genericArrayType .getGenericComponentType()), 0); return rawArrayType.getClass(); } else if (type instanceof WildcardType) { WildcardType castedType = (WildcardType) type; return getRawType(castedType.getUpperBounds()[0]); } else { throw new IllegalArgumentException( "Type \'" + type + "\' is not a Class, " + "ParameterizedType, or GenericArrayType. Can't extract class."); } }
java
public static Class<?> getRawType(Type type) { if (type instanceof Class) { return (Class<?>) type; } else if (type instanceof ParameterizedType) { ParameterizedType actualType = (ParameterizedType) type; return getRawType(actualType.getRawType()); } else if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; Object rawArrayType = Array.newInstance(getRawType(genericArrayType .getGenericComponentType()), 0); return rawArrayType.getClass(); } else if (type instanceof WildcardType) { WildcardType castedType = (WildcardType) type; return getRawType(castedType.getUpperBounds()[0]); } else { throw new IllegalArgumentException( "Type \'" + type + "\' is not a Class, " + "ParameterizedType, or GenericArrayType. Can't extract class."); } }
[ "public", "static", "Class", "<", "?", ">", "getRawType", "(", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "Class", ")", "{", "return", "(", "Class", "<", "?", ">", ")", "type", ";", "}", "else", "if", "(", "type", "instanceof", "ParameterizedType", ")", "{", "ParameterizedType", "actualType", "=", "(", "ParameterizedType", ")", "type", ";", "return", "getRawType", "(", "actualType", ".", "getRawType", "(", ")", ")", ";", "}", "else", "if", "(", "type", "instanceof", "GenericArrayType", ")", "{", "GenericArrayType", "genericArrayType", "=", "(", "GenericArrayType", ")", "type", ";", "Object", "rawArrayType", "=", "Array", ".", "newInstance", "(", "getRawType", "(", "genericArrayType", ".", "getGenericComponentType", "(", ")", ")", ",", "0", ")", ";", "return", "rawArrayType", ".", "getClass", "(", ")", ";", "}", "else", "if", "(", "type", "instanceof", "WildcardType", ")", "{", "WildcardType", "castedType", "=", "(", "WildcardType", ")", "type", ";", "return", "getRawType", "(", "castedType", ".", "getUpperBounds", "(", ")", "[", "0", "]", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Type \\'\"", "+", "type", "+", "\"\\' is not a Class, \"", "+", "\"ParameterizedType, or GenericArrayType. Can't extract class.\"", ")", ";", "}", "}" ]
This method returns the actual raw class associated with the specified type.
[ "This", "method", "returns", "the", "actual", "raw", "class", "associated", "with", "the", "specified", "type", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeUtils.java#L39-L60
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeUtils.java
TypeUtils.isAssignableFrom
public static boolean isAssignableFrom(TypeReference<?> from, TypeReference<?> to) { if (from == null) { return false; } if (to.equals(from)) { return true; } if (to.getType() instanceof Class) { return to.getRawType().isAssignableFrom(from.getRawType()); } else if (to.getType() instanceof ParameterizedType) { return isAssignableFrom(from.getType(), (ParameterizedType) to .getType(), new HashMap<String, Type>()); } else if (to.getType() instanceof GenericArrayType) { return to.getRawType().isAssignableFrom(from.getRawType()) && isAssignableFrom(from.getType(), (GenericArrayType) to .getType()); } else { throw new AssertionError("Unexpected Type : " + to); } }
java
public static boolean isAssignableFrom(TypeReference<?> from, TypeReference<?> to) { if (from == null) { return false; } if (to.equals(from)) { return true; } if (to.getType() instanceof Class) { return to.getRawType().isAssignableFrom(from.getRawType()); } else if (to.getType() instanceof ParameterizedType) { return isAssignableFrom(from.getType(), (ParameterizedType) to .getType(), new HashMap<String, Type>()); } else if (to.getType() instanceof GenericArrayType) { return to.getRawType().isAssignableFrom(from.getRawType()) && isAssignableFrom(from.getType(), (GenericArrayType) to .getType()); } else { throw new AssertionError("Unexpected Type : " + to); } }
[ "public", "static", "boolean", "isAssignableFrom", "(", "TypeReference", "<", "?", ">", "from", ",", "TypeReference", "<", "?", ">", "to", ")", "{", "if", "(", "from", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "to", ".", "equals", "(", "from", ")", ")", "{", "return", "true", ";", "}", "if", "(", "to", ".", "getType", "(", ")", "instanceof", "Class", ")", "{", "return", "to", ".", "getRawType", "(", ")", ".", "isAssignableFrom", "(", "from", ".", "getRawType", "(", ")", ")", ";", "}", "else", "if", "(", "to", ".", "getType", "(", ")", "instanceof", "ParameterizedType", ")", "{", "return", "isAssignableFrom", "(", "from", ".", "getType", "(", ")", ",", "(", "ParameterizedType", ")", "to", ".", "getType", "(", ")", ",", "new", "HashMap", "<", "String", ",", "Type", ">", "(", ")", ")", ";", "}", "else", "if", "(", "to", ".", "getType", "(", ")", "instanceof", "GenericArrayType", ")", "{", "return", "to", ".", "getRawType", "(", ")", ".", "isAssignableFrom", "(", "from", ".", "getRawType", "(", ")", ")", "&&", "isAssignableFrom", "(", "from", ".", "getType", "(", ")", ",", "(", "GenericArrayType", ")", "to", ".", "getType", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "AssertionError", "(", "\"Unexpected Type : \"", "+", "to", ")", ";", "}", "}" ]
Check if this type is assignable from the given Type.
[ "Check", "if", "this", "type", "is", "assignable", "from", "the", "given", "Type", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeUtils.java#L66-L87
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeUtils.java
TypeUtils.isAssignableFrom
private static boolean isAssignableFrom(Type from, ParameterizedType to, Map<String, Type> typeVarMap) { if (from == null) { return false; } if (to.equals(from)) { return true; } // First figure out the class and any type information. Class<?> clazz = getRawType(from); ParameterizedType ptype = null; if (from instanceof ParameterizedType) { ptype = (ParameterizedType) from; } // Load up parameterized variable info if it was parameterized. if (ptype != null) { Type[] tArgs = ptype.getActualTypeArguments(); TypeVariable<?>[] tParams = clazz.getTypeParameters(); for (int i = 0; i < tArgs.length; i++) { Type arg = tArgs[i]; TypeVariable<?> var = tParams[i]; while (arg instanceof TypeVariable) { TypeVariable<?> v = (TypeVariable<?>) arg; arg = typeVarMap.get(v.getName()); } typeVarMap.put(var.getName(), arg); } // check if they are equivalent under our current mapping. if (typeEquals(ptype, to, typeVarMap)) { return true; } } for (Type itype : clazz.getGenericInterfaces()) { if (isAssignableFrom(itype, to, new HashMap<String, Type>( typeVarMap))) { return true; } } // Interfaces didn't work, try the superclass. Type sType = clazz.getGenericSuperclass(); if (isAssignableFrom(sType, to, new HashMap<String, Type>(typeVarMap))) { return true; } return false; }
java
private static boolean isAssignableFrom(Type from, ParameterizedType to, Map<String, Type> typeVarMap) { if (from == null) { return false; } if (to.equals(from)) { return true; } // First figure out the class and any type information. Class<?> clazz = getRawType(from); ParameterizedType ptype = null; if (from instanceof ParameterizedType) { ptype = (ParameterizedType) from; } // Load up parameterized variable info if it was parameterized. if (ptype != null) { Type[] tArgs = ptype.getActualTypeArguments(); TypeVariable<?>[] tParams = clazz.getTypeParameters(); for (int i = 0; i < tArgs.length; i++) { Type arg = tArgs[i]; TypeVariable<?> var = tParams[i]; while (arg instanceof TypeVariable) { TypeVariable<?> v = (TypeVariable<?>) arg; arg = typeVarMap.get(v.getName()); } typeVarMap.put(var.getName(), arg); } // check if they are equivalent under our current mapping. if (typeEquals(ptype, to, typeVarMap)) { return true; } } for (Type itype : clazz.getGenericInterfaces()) { if (isAssignableFrom(itype, to, new HashMap<String, Type>( typeVarMap))) { return true; } } // Interfaces didn't work, try the superclass. Type sType = clazz.getGenericSuperclass(); if (isAssignableFrom(sType, to, new HashMap<String, Type>(typeVarMap))) { return true; } return false; }
[ "private", "static", "boolean", "isAssignableFrom", "(", "Type", "from", ",", "ParameterizedType", "to", ",", "Map", "<", "String", ",", "Type", ">", "typeVarMap", ")", "{", "if", "(", "from", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "to", ".", "equals", "(", "from", ")", ")", "{", "return", "true", ";", "}", "// First figure out the class and any type information.", "Class", "<", "?", ">", "clazz", "=", "getRawType", "(", "from", ")", ";", "ParameterizedType", "ptype", "=", "null", ";", "if", "(", "from", "instanceof", "ParameterizedType", ")", "{", "ptype", "=", "(", "ParameterizedType", ")", "from", ";", "}", "// Load up parameterized variable info if it was parameterized.", "if", "(", "ptype", "!=", "null", ")", "{", "Type", "[", "]", "tArgs", "=", "ptype", ".", "getActualTypeArguments", "(", ")", ";", "TypeVariable", "<", "?", ">", "[", "]", "tParams", "=", "clazz", ".", "getTypeParameters", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tArgs", ".", "length", ";", "i", "++", ")", "{", "Type", "arg", "=", "tArgs", "[", "i", "]", ";", "TypeVariable", "<", "?", ">", "var", "=", "tParams", "[", "i", "]", ";", "while", "(", "arg", "instanceof", "TypeVariable", ")", "{", "TypeVariable", "<", "?", ">", "v", "=", "(", "TypeVariable", "<", "?", ">", ")", "arg", ";", "arg", "=", "typeVarMap", ".", "get", "(", "v", ".", "getName", "(", ")", ")", ";", "}", "typeVarMap", ".", "put", "(", "var", ".", "getName", "(", ")", ",", "arg", ")", ";", "}", "// check if they are equivalent under our current mapping.", "if", "(", "typeEquals", "(", "ptype", ",", "to", ",", "typeVarMap", ")", ")", "{", "return", "true", ";", "}", "}", "for", "(", "Type", "itype", ":", "clazz", ".", "getGenericInterfaces", "(", ")", ")", "{", "if", "(", "isAssignableFrom", "(", "itype", ",", "to", ",", "new", "HashMap", "<", "String", ",", "Type", ">", "(", "typeVarMap", ")", ")", ")", "{", "return", "true", ";", "}", "}", "// Interfaces didn't work, try the superclass.", "Type", "sType", "=", "clazz", ".", "getGenericSuperclass", "(", ")", ";", "if", "(", "isAssignableFrom", "(", "sType", ",", "to", ",", "new", "HashMap", "<", "String", ",", "Type", ">", "(", "typeVarMap", ")", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Private recursive helper function to actually do the type-safe checking of assignability.
[ "Private", "recursive", "helper", "function", "to", "actually", "do", "the", "type", "-", "safe", "checking", "of", "assignability", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeUtils.java#L93-L145
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeUtils.java
TypeUtils.typeEquals
private static boolean typeEquals(ParameterizedType from, ParameterizedType to, Map<String, Type> typeVarMap) { if (from.getRawType().equals(to.getRawType())) { Type[] fromArgs = from.getActualTypeArguments(); Type[] toArgs = to.getActualTypeArguments(); for (int i = 0; i < fromArgs.length; i++) { if (!matches(fromArgs[i], toArgs[i], typeVarMap)) { return false; } } return true; } return false; }
java
private static boolean typeEquals(ParameterizedType from, ParameterizedType to, Map<String, Type> typeVarMap) { if (from.getRawType().equals(to.getRawType())) { Type[] fromArgs = from.getActualTypeArguments(); Type[] toArgs = to.getActualTypeArguments(); for (int i = 0; i < fromArgs.length; i++) { if (!matches(fromArgs[i], toArgs[i], typeVarMap)) { return false; } } return true; } return false; }
[ "private", "static", "boolean", "typeEquals", "(", "ParameterizedType", "from", ",", "ParameterizedType", "to", ",", "Map", "<", "String", ",", "Type", ">", "typeVarMap", ")", "{", "if", "(", "from", ".", "getRawType", "(", ")", ".", "equals", "(", "to", ".", "getRawType", "(", ")", ")", ")", "{", "Type", "[", "]", "fromArgs", "=", "from", ".", "getActualTypeArguments", "(", ")", ";", "Type", "[", "]", "toArgs", "=", "to", ".", "getActualTypeArguments", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fromArgs", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "matches", "(", "fromArgs", "[", "i", "]", ",", "toArgs", "[", "i", "]", ",", "typeVarMap", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if two parameterized types are exactly equal, under the variable replacement described in the typeVarMap.
[ "Checks", "if", "two", "parameterized", "types", "are", "exactly", "equal", "under", "the", "variable", "replacement", "described", "in", "the", "typeVarMap", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeUtils.java#L151-L164
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeUtils.java
TypeUtils.matches
private static boolean matches(Type from, Type to, Map<String, Type> typeMap) { if (to.equals(from)) return true; if (from instanceof TypeVariable) { return to.equals(typeMap.get(((TypeVariable<?>) from).getName())); } return false; }
java
private static boolean matches(Type from, Type to, Map<String, Type> typeMap) { if (to.equals(from)) return true; if (from instanceof TypeVariable) { return to.equals(typeMap.get(((TypeVariable<?>) from).getName())); } return false; }
[ "private", "static", "boolean", "matches", "(", "Type", "from", ",", "Type", "to", ",", "Map", "<", "String", ",", "Type", ">", "typeMap", ")", "{", "if", "(", "to", ".", "equals", "(", "from", ")", ")", "return", "true", ";", "if", "(", "from", "instanceof", "TypeVariable", ")", "{", "return", "to", ".", "equals", "(", "typeMap", ".", "get", "(", "(", "(", "TypeVariable", "<", "?", ">", ")", "from", ")", ".", "getName", "(", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Checks if two types are the same or are equivalent under a variable mapping given in the type map that was provided.
[ "Checks", "if", "two", "types", "are", "the", "same", "or", "are", "equivalent", "under", "a", "variable", "mapping", "given", "in", "the", "type", "map", "that", "was", "provided", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeUtils.java#L170-L179
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/type/TypeUtils.java
TypeUtils.isAssignableFrom
private static boolean isAssignableFrom(Type from, GenericArrayType to) { Type toGenericComponentType = to.getGenericComponentType(); if (toGenericComponentType instanceof ParameterizedType) { Type t = from; if (from instanceof GenericArrayType) { t = ((GenericArrayType) from).getGenericComponentType(); } else if (from instanceof Class) { Class<?> classType = (Class<?>) from; while (classType.isArray()) { classType = classType.getComponentType(); } t = classType; } return isAssignableFrom(t, (ParameterizedType) toGenericComponentType, new HashMap<String, Type>()); } // No generic defined on "to"; therefore, return true and let other // checks determine assignability return true; }
java
private static boolean isAssignableFrom(Type from, GenericArrayType to) { Type toGenericComponentType = to.getGenericComponentType(); if (toGenericComponentType instanceof ParameterizedType) { Type t = from; if (from instanceof GenericArrayType) { t = ((GenericArrayType) from).getGenericComponentType(); } else if (from instanceof Class) { Class<?> classType = (Class<?>) from; while (classType.isArray()) { classType = classType.getComponentType(); } t = classType; } return isAssignableFrom(t, (ParameterizedType) toGenericComponentType, new HashMap<String, Type>()); } // No generic defined on "to"; therefore, return true and let other // checks determine assignability return true; }
[ "private", "static", "boolean", "isAssignableFrom", "(", "Type", "from", ",", "GenericArrayType", "to", ")", "{", "Type", "toGenericComponentType", "=", "to", ".", "getGenericComponentType", "(", ")", ";", "if", "(", "toGenericComponentType", "instanceof", "ParameterizedType", ")", "{", "Type", "t", "=", "from", ";", "if", "(", "from", "instanceof", "GenericArrayType", ")", "{", "t", "=", "(", "(", "GenericArrayType", ")", "from", ")", ".", "getGenericComponentType", "(", ")", ";", "}", "else", "if", "(", "from", "instanceof", "Class", ")", "{", "Class", "<", "?", ">", "classType", "=", "(", "Class", "<", "?", ">", ")", "from", ";", "while", "(", "classType", ".", "isArray", "(", ")", ")", "{", "classType", "=", "classType", ".", "getComponentType", "(", ")", ";", "}", "t", "=", "classType", ";", "}", "return", "isAssignableFrom", "(", "t", ",", "(", "ParameterizedType", ")", "toGenericComponentType", ",", "new", "HashMap", "<", "String", ",", "Type", ">", "(", ")", ")", ";", "}", "// No generic defined on \"to\"; therefore, return true and let other", "// checks determine assignability", "return", "true", ";", "}" ]
Private helper function that performs some assignability checks for the provided GenericArrayType.
[ "Private", "helper", "function", "that", "performs", "some", "assignability", "checks", "for", "the", "provided", "GenericArrayType", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/type/TypeUtils.java#L185-L205
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java
SingleListBox.setValue
@Override public void setValue(String value, boolean fireEvents) { boolean added = setSelectedValue(this, value, addMissingValue); if (added && fireEvents) { ValueChangeEvent.fire(this, getValue()); } }
java
@Override public void setValue(String value, boolean fireEvents) { boolean added = setSelectedValue(this, value, addMissingValue); if (added && fireEvents) { ValueChangeEvent.fire(this, getValue()); } }
[ "@", "Override", "public", "void", "setValue", "(", "String", "value", ",", "boolean", "fireEvents", ")", "{", "boolean", "added", "=", "setSelectedValue", "(", "this", ",", "value", ",", "addMissingValue", ")", ";", "if", "(", "added", "&&", "fireEvents", ")", "{", "ValueChangeEvent", ".", "fire", "(", "this", ",", "getValue", "(", ")", ")", ";", "}", "}" ]
Selects the specified value in the list. @param value the new value @param fireEvents if true, a ValueChangeEvent event will be fired @see #setAddMissingValue
[ "Selects", "the", "specified", "value", "in", "the", "list", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java#L116-L122
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java
SingleListBox.getSelectedValue
public static final String getSelectedValue(ListBox list) { int index = list.getSelectedIndex(); return (index >= 0) ? list.getValue(index) : null; }
java
public static final String getSelectedValue(ListBox list) { int index = list.getSelectedIndex(); return (index >= 0) ? list.getValue(index) : null; }
[ "public", "static", "final", "String", "getSelectedValue", "(", "ListBox", "list", ")", "{", "int", "index", "=", "list", ".", "getSelectedIndex", "(", ")", ";", "return", "(", "index", ">=", "0", ")", "?", "list", ".", "getValue", "(", "index", ")", ":", "null", ";", "}" ]
Utility function to get the current value.
[ "Utility", "function", "to", "get", "the", "current", "value", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java#L146-L149
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java
SingleListBox.getSelectedText
public static final String getSelectedText(ListBox list) { int index = list.getSelectedIndex(); return (index >= 0) ? list.getItemText(index) : null; }
java
public static final String getSelectedText(ListBox list) { int index = list.getSelectedIndex(); return (index >= 0) ? list.getItemText(index) : null; }
[ "public", "static", "final", "String", "getSelectedText", "(", "ListBox", "list", ")", "{", "int", "index", "=", "list", ".", "getSelectedIndex", "(", ")", ";", "return", "(", "index", ">=", "0", ")", "?", "list", ".", "getItemText", "(", "index", ")", ":", "null", ";", "}" ]
Utility function to get the current text.
[ "Utility", "function", "to", "get", "the", "current", "text", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java#L154-L157
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java
SingleListBox.findValueInListBox
public static final int findValueInListBox(ListBox list, String value) { for (int i=0; i<list.getItemCount(); i++) { if (value.equals(list.getValue(i))) { return i; } } return -1; }
java
public static final int findValueInListBox(ListBox list, String value) { for (int i=0; i<list.getItemCount(); i++) { if (value.equals(list.getValue(i))) { return i; } } return -1; }
[ "public", "static", "final", "int", "findValueInListBox", "(", "ListBox", "list", ",", "String", "value", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "getItemCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "value", ".", "equals", "(", "list", ".", "getValue", "(", "i", ")", ")", ")", "{", "return", "i", ";", "}", "}", "return", "-", "1", ";", "}" ]
Utility function to find the first index of a value in a ListBox.
[ "Utility", "function", "to", "find", "the", "first", "index", "of", "a", "value", "in", "a", "ListBox", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java#L163-L170
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java
SingleListBox.setSelectedValue
public static final boolean setSelectedValue(ListBox list, String value, boolean addMissingValues) { if (value == null) { list.setSelectedIndex(0); return false; } else { int index = findValueInListBox(list, value); if (index >= 0) { list.setSelectedIndex(index); return true; } if (addMissingValues) { list.addItem(value, value); // now that it's there, search again index = findValueInListBox(list, value); list.setSelectedIndex(index); return true; } return false; } }
java
public static final boolean setSelectedValue(ListBox list, String value, boolean addMissingValues) { if (value == null) { list.setSelectedIndex(0); return false; } else { int index = findValueInListBox(list, value); if (index >= 0) { list.setSelectedIndex(index); return true; } if (addMissingValues) { list.addItem(value, value); // now that it's there, search again index = findValueInListBox(list, value); list.setSelectedIndex(index); return true; } return false; } }
[ "public", "static", "final", "boolean", "setSelectedValue", "(", "ListBox", "list", ",", "String", "value", ",", "boolean", "addMissingValues", ")", "{", "if", "(", "value", "==", "null", ")", "{", "list", ".", "setSelectedIndex", "(", "0", ")", ";", "return", "false", ";", "}", "else", "{", "int", "index", "=", "findValueInListBox", "(", "list", ",", "value", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "list", ".", "setSelectedIndex", "(", "index", ")", ";", "return", "true", ";", "}", "if", "(", "addMissingValues", ")", "{", "list", ".", "addItem", "(", "value", ",", "value", ")", ";", "// now that it's there, search again", "index", "=", "findValueInListBox", "(", "list", ",", "value", ")", ";", "list", ".", "setSelectedIndex", "(", "index", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "}" ]
Utility function to set the current value in a ListBox. @return returns true if the option corresponding to the value was successfully selected in the ListBox
[ "Utility", "function", "to", "set", "the", "current", "value", "in", "a", "ListBox", "." ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/SingleListBox.java#L178-L201
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/utils/BeanUtils.java
BeanUtils.capitalizePropertyName
public static String capitalizePropertyName(String s) { if (s.length() == 0) { return s; } char[] chars = s.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); }
java
public static String capitalizePropertyName(String s) { if (s.length() == 0) { return s; } char[] chars = s.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); }
[ "public", "static", "String", "capitalizePropertyName", "(", "String", "s", ")", "{", "if", "(", "s", ".", "length", "(", ")", "==", "0", ")", "{", "return", "s", ";", "}", "char", "[", "]", "chars", "=", "s", ".", "toCharArray", "(", ")", ";", "chars", "[", "0", "]", "=", "Character", ".", "toUpperCase", "(", "chars", "[", "0", "]", ")", ";", "return", "new", "String", "(", "chars", ")", ";", "}" ]
Return a capitalized version of the specified property name. @param s The property name
[ "Return", "a", "capitalized", "version", "of", "the", "specified", "property", "name", "." ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/utils/BeanUtils.java#L36-L44
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/utils/BeanUtils.java
BeanUtils.getGetterPropertyMethod
public static Method getGetterPropertyMethod(Class<?> type, String propertyName) { String sourceMethodName = "get" + BeanUtils.capitalizePropertyName(propertyName); Method sourceMethod = BeanUtils.getMethod(type, sourceMethodName); if (sourceMethod == null) { sourceMethodName = "is" + BeanUtils.capitalizePropertyName(propertyName); sourceMethod = BeanUtils.getMethod(type, sourceMethodName); if (sourceMethod != null && sourceMethod.getReturnType() != Boolean.TYPE) { sourceMethod = null; } } return sourceMethod; }
java
public static Method getGetterPropertyMethod(Class<?> type, String propertyName) { String sourceMethodName = "get" + BeanUtils.capitalizePropertyName(propertyName); Method sourceMethod = BeanUtils.getMethod(type, sourceMethodName); if (sourceMethod == null) { sourceMethodName = "is" + BeanUtils.capitalizePropertyName(propertyName); sourceMethod = BeanUtils.getMethod(type, sourceMethodName); if (sourceMethod != null && sourceMethod.getReturnType() != Boolean.TYPE) { sourceMethod = null; } } return sourceMethod; }
[ "public", "static", "Method", "getGetterPropertyMethod", "(", "Class", "<", "?", ">", "type", ",", "String", "propertyName", ")", "{", "String", "sourceMethodName", "=", "\"get\"", "+", "BeanUtils", ".", "capitalizePropertyName", "(", "propertyName", ")", ";", "Method", "sourceMethod", "=", "BeanUtils", ".", "getMethod", "(", "type", ",", "sourceMethodName", ")", ";", "if", "(", "sourceMethod", "==", "null", ")", "{", "sourceMethodName", "=", "\"is\"", "+", "BeanUtils", ".", "capitalizePropertyName", "(", "propertyName", ")", ";", "sourceMethod", "=", "BeanUtils", ".", "getMethod", "(", "type", ",", "sourceMethodName", ")", ";", "if", "(", "sourceMethod", "!=", "null", "&&", "sourceMethod", ".", "getReturnType", "(", ")", "!=", "Boolean", ".", "TYPE", ")", "{", "sourceMethod", "=", "null", ";", "}", "}", "return", "sourceMethod", ";", "}" ]
get the getter method corresponding to given property
[ "get", "the", "getter", "method", "corresponding", "to", "given", "property" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/utils/BeanUtils.java#L128-L145
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/utils/BeanUtils.java
BeanUtils.getSetterPropertyMethod
public static Method getSetterPropertyMethod(Class<?> type, String propertyName) { String sourceMethodName = "set" + BeanUtils.capitalizePropertyName(propertyName); Method sourceMethod = BeanUtils.getMethod(type, sourceMethodName); return sourceMethod; }
java
public static Method getSetterPropertyMethod(Class<?> type, String propertyName) { String sourceMethodName = "set" + BeanUtils.capitalizePropertyName(propertyName); Method sourceMethod = BeanUtils.getMethod(type, sourceMethodName); return sourceMethod; }
[ "public", "static", "Method", "getSetterPropertyMethod", "(", "Class", "<", "?", ">", "type", ",", "String", "propertyName", ")", "{", "String", "sourceMethodName", "=", "\"set\"", "+", "BeanUtils", ".", "capitalizePropertyName", "(", "propertyName", ")", ";", "Method", "sourceMethod", "=", "BeanUtils", ".", "getMethod", "(", "type", ",", "sourceMethodName", ")", ";", "return", "sourceMethod", ";", "}" ]
get the setter method corresponding to given property
[ "get", "the", "setter", "method", "corresponding", "to", "given", "property" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/utils/BeanUtils.java#L151-L159
train
matiwinnetou/spring-soy-view
spring-soy-view/src/main/java/pl/matisoft/soy/data/NoConvertSoyDataConverter.java
NoConvertSoyDataConverter.toSoyMap
@Override public Optional<SoyMapData> toSoyMap(@Nullable final Object model) throws Exception { if (model instanceof SoyMapData) { return Optional.of((SoyMapData) model); } if (model instanceof Map) { return Optional.of(new SoyMapData(model)); } return Optional.of(new SoyMapData()); }
java
@Override public Optional<SoyMapData> toSoyMap(@Nullable final Object model) throws Exception { if (model instanceof SoyMapData) { return Optional.of((SoyMapData) model); } if (model instanceof Map) { return Optional.of(new SoyMapData(model)); } return Optional.of(new SoyMapData()); }
[ "@", "Override", "public", "Optional", "<", "SoyMapData", ">", "toSoyMap", "(", "@", "Nullable", "final", "Object", "model", ")", "throws", "Exception", "{", "if", "(", "model", "instanceof", "SoyMapData", ")", "{", "return", "Optional", ".", "of", "(", "(", "SoyMapData", ")", "model", ")", ";", "}", "if", "(", "model", "instanceof", "Map", ")", "{", "return", "Optional", ".", "of", "(", "new", "SoyMapData", "(", "model", ")", ")", ";", "}", "return", "Optional", ".", "of", "(", "new", "SoyMapData", "(", ")", ")", ";", "}" ]
Pass a model object and return a SoyMapData if a model object happens to be a SoyMapData. An implementation will also check if a passed in object is a Map and return a SoyMapData wrapping that map
[ "Pass", "a", "model", "object", "and", "return", "a", "SoyMapData", "if", "a", "model", "object", "happens", "to", "be", "a", "SoyMapData", "." ]
a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1
https://github.com/matiwinnetou/spring-soy-view/blob/a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1/spring-soy-view/src/main/java/pl/matisoft/soy/data/NoConvertSoyDataConverter.java#L28-L38
train
tractionsoftware/gwt-traction
src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java
AutoSizingTextArea.getShadowSize
@Override public int getShadowSize() { Element shadowElement = shadow.getElement(); shadowElement.setScrollTop(10000); return shadowElement.getScrollTop(); }
java
@Override public int getShadowSize() { Element shadowElement = shadow.getElement(); shadowElement.setScrollTop(10000); return shadowElement.getScrollTop(); }
[ "@", "Override", "public", "int", "getShadowSize", "(", ")", "{", "Element", "shadowElement", "=", "shadow", ".", "getElement", "(", ")", ";", "shadowElement", ".", "setScrollTop", "(", "10000", ")", ";", "return", "shadowElement", ".", "getScrollTop", "(", ")", ";", "}" ]
Returns the size of the shadow element
[ "Returns", "the", "size", "of", "the", "shadow", "element" ]
efc1423c619439763fb064b777b7235e9ce414a3
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/AutoSizingTextArea.java#L102-L107
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/context/ConvertedObjectPool.java
ConvertedObjectPool.get
public Object get(IConverter converter, Object sourceObject, TypeReference<?> destinationType) { return convertedObjects.get(new ConvertedObjectsKey(converter, sourceObject, destinationType)); }
java
public Object get(IConverter converter, Object sourceObject, TypeReference<?> destinationType) { return convertedObjects.get(new ConvertedObjectsKey(converter, sourceObject, destinationType)); }
[ "public", "Object", "get", "(", "IConverter", "converter", ",", "Object", "sourceObject", ",", "TypeReference", "<", "?", ">", "destinationType", ")", "{", "return", "convertedObjects", ".", "get", "(", "new", "ConvertedObjectsKey", "(", "converter", ",", "sourceObject", ",", "destinationType", ")", ")", ";", "}" ]
get the converted object corresponding to sourceObject as converted to destination type by converter @param converter @param sourceObject @param destinationType @return
[ "get", "the", "converted", "object", "corresponding", "to", "sourceObject", "as", "converted", "to", "destination", "type", "by", "converter" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/context/ConvertedObjectPool.java#L43-L47
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/context/ConvertedObjectPool.java
ConvertedObjectPool.add
public void add(IConverter converter, Object sourceObject, TypeReference<?> destinationType, Object convertedObject) { convertedObjects.put(new ConvertedObjectsKey(converter, sourceObject, destinationType), convertedObject); }
java
public void add(IConverter converter, Object sourceObject, TypeReference<?> destinationType, Object convertedObject) { convertedObjects.put(new ConvertedObjectsKey(converter, sourceObject, destinationType), convertedObject); }
[ "public", "void", "add", "(", "IConverter", "converter", ",", "Object", "sourceObject", ",", "TypeReference", "<", "?", ">", "destinationType", ",", "Object", "convertedObject", ")", "{", "convertedObjects", ".", "put", "(", "new", "ConvertedObjectsKey", "(", "converter", ",", "sourceObject", ",", "destinationType", ")", ",", "convertedObject", ")", ";", "}" ]
add a converted object to the pool @param converter the converter that made the conversion @param sourceObject the source object that has been converted @param destinationType the destination type @param convertedObject the converted object
[ "add", "a", "converted", "object", "to", "the", "pool" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/context/ConvertedObjectPool.java#L61-L65
train
cchabanois/transmorph
src/main/java/net/entropysoft/transmorph/context/ConvertedObjectPool.java
ConvertedObjectPool.remove
public void remove(IConverter converter, Object sourceObject, TypeReference<?> destinationType) { convertedObjects.remove(new ConvertedObjectsKey(converter, sourceObject, destinationType)); }
java
public void remove(IConverter converter, Object sourceObject, TypeReference<?> destinationType) { convertedObjects.remove(new ConvertedObjectsKey(converter, sourceObject, destinationType)); }
[ "public", "void", "remove", "(", "IConverter", "converter", ",", "Object", "sourceObject", ",", "TypeReference", "<", "?", ">", "destinationType", ")", "{", "convertedObjects", ".", "remove", "(", "new", "ConvertedObjectsKey", "(", "converter", ",", "sourceObject", ",", "destinationType", ")", ")", ";", "}" ]
remove a converted object from the pool @param converter @param sourceObject @param destinationType
[ "remove", "a", "converted", "object", "from", "the", "pool" ]
118550f30b9680a84eab7496bd8b04118740dcec
https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/context/ConvertedObjectPool.java#L74-L78
train