id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
7,700 |
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java
|
GenericRepository.find
|
@Transactional
public List<E> find(E entity, SearchParameters sp) {
if (sp.hasNamedQuery()) {
return byNamedQueryUtil.findByNamedQuery(sp);
}
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<E> criteriaQuery = builder.createQuery(type);
if (sp.getDistinct()) {
criteriaQuery.distinct(true);
}
Root<E> root = criteriaQuery.from(type);
// predicate
Predicate predicate = getPredicate(criteriaQuery, root, builder, entity, sp);
if (predicate != null) {
criteriaQuery = criteriaQuery.where(predicate);
}
// fetches
fetches(sp, root);
// order by
criteriaQuery.orderBy(orderByUtil.buildJpaOrders(sp.getOrders(), root, builder, sp));
TypedQuery<E> typedQuery = entityManager.createQuery(criteriaQuery);
applyCacheHints(typedQuery, sp);
jpaUtil.applyPagination(typedQuery, sp);
List<E> entities = typedQuery.getResultList();
log.fine("Returned " + entities.size() + " elements");
return entities;
}
|
java
|
@Transactional
public List<E> find(E entity, SearchParameters sp) {
if (sp.hasNamedQuery()) {
return byNamedQueryUtil.findByNamedQuery(sp);
}
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<E> criteriaQuery = builder.createQuery(type);
if (sp.getDistinct()) {
criteriaQuery.distinct(true);
}
Root<E> root = criteriaQuery.from(type);
// predicate
Predicate predicate = getPredicate(criteriaQuery, root, builder, entity, sp);
if (predicate != null) {
criteriaQuery = criteriaQuery.where(predicate);
}
// fetches
fetches(sp, root);
// order by
criteriaQuery.orderBy(orderByUtil.buildJpaOrders(sp.getOrders(), root, builder, sp));
TypedQuery<E> typedQuery = entityManager.createQuery(criteriaQuery);
applyCacheHints(typedQuery, sp);
jpaUtil.applyPagination(typedQuery, sp);
List<E> entities = typedQuery.getResultList();
log.fine("Returned " + entities.size() + " elements");
return entities;
}
|
[
"@",
"Transactional",
"public",
"List",
"<",
"E",
">",
"find",
"(",
"E",
"entity",
",",
"SearchParameters",
"sp",
")",
"{",
"if",
"(",
"sp",
".",
"hasNamedQuery",
"(",
")",
")",
"{",
"return",
"byNamedQueryUtil",
".",
"findByNamedQuery",
"(",
"sp",
")",
";",
"}",
"CriteriaBuilder",
"builder",
"=",
"entityManager",
".",
"getCriteriaBuilder",
"(",
")",
";",
"CriteriaQuery",
"<",
"E",
">",
"criteriaQuery",
"=",
"builder",
".",
"createQuery",
"(",
"type",
")",
";",
"if",
"(",
"sp",
".",
"getDistinct",
"(",
")",
")",
"{",
"criteriaQuery",
".",
"distinct",
"(",
"true",
")",
";",
"}",
"Root",
"<",
"E",
">",
"root",
"=",
"criteriaQuery",
".",
"from",
"(",
"type",
")",
";",
"// predicate",
"Predicate",
"predicate",
"=",
"getPredicate",
"(",
"criteriaQuery",
",",
"root",
",",
"builder",
",",
"entity",
",",
"sp",
")",
";",
"if",
"(",
"predicate",
"!=",
"null",
")",
"{",
"criteriaQuery",
"=",
"criteriaQuery",
".",
"where",
"(",
"predicate",
")",
";",
"}",
"// fetches",
"fetches",
"(",
"sp",
",",
"root",
")",
";",
"// order by",
"criteriaQuery",
".",
"orderBy",
"(",
"orderByUtil",
".",
"buildJpaOrders",
"(",
"sp",
".",
"getOrders",
"(",
")",
",",
"root",
",",
"builder",
",",
"sp",
")",
")",
";",
"TypedQuery",
"<",
"E",
">",
"typedQuery",
"=",
"entityManager",
".",
"createQuery",
"(",
"criteriaQuery",
")",
";",
"applyCacheHints",
"(",
"typedQuery",
",",
"sp",
")",
";",
"jpaUtil",
".",
"applyPagination",
"(",
"typedQuery",
",",
"sp",
")",
";",
"List",
"<",
"E",
">",
"entities",
"=",
"typedQuery",
".",
"getResultList",
"(",
")",
";",
"log",
".",
"fine",
"(",
"\"Returned \"",
"+",
"entities",
".",
"size",
"(",
")",
"+",
"\" elements\"",
")",
";",
"return",
"entities",
";",
"}"
] |
Find and load a list of E instance.
@param entity a sample entity whose non-null properties may be used as search hints
@param sp carries additional search information
@return the entities matching the search.
|
[
"Find",
"and",
"load",
"a",
"list",
"of",
"E",
"instance",
"."
] |
61238b967952446d81cc68424a4e809093a77fcf
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java#L202-L233
|
7,701 |
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java
|
GenericRepository.save
|
@Transactional
public void save(E entity) {
checkNotNull(entity, "The entity to save cannot be null");
// creation with auto generated id
if (!entity.isIdSet()) {
entityManager.persist(entity);
return;
}
// creation with manually assigned key
if (jpaUtil.isEntityIdManuallyAssigned(type) && !entityManager.contains(entity)) {
entityManager.persist(entity);
return;
}
// other cases are update
// the simple fact to invoke this method, from a service method annotated with @Transactional,
// does the job (assuming the give entity is present in the persistence context)
}
|
java
|
@Transactional
public void save(E entity) {
checkNotNull(entity, "The entity to save cannot be null");
// creation with auto generated id
if (!entity.isIdSet()) {
entityManager.persist(entity);
return;
}
// creation with manually assigned key
if (jpaUtil.isEntityIdManuallyAssigned(type) && !entityManager.contains(entity)) {
entityManager.persist(entity);
return;
}
// other cases are update
// the simple fact to invoke this method, from a service method annotated with @Transactional,
// does the job (assuming the give entity is present in the persistence context)
}
|
[
"@",
"Transactional",
"public",
"void",
"save",
"(",
"E",
"entity",
")",
"{",
"checkNotNull",
"(",
"entity",
",",
"\"The entity to save cannot be null\"",
")",
";",
"// creation with auto generated id",
"if",
"(",
"!",
"entity",
".",
"isIdSet",
"(",
")",
")",
"{",
"entityManager",
".",
"persist",
"(",
"entity",
")",
";",
"return",
";",
"}",
"// creation with manually assigned key",
"if",
"(",
"jpaUtil",
".",
"isEntityIdManuallyAssigned",
"(",
"type",
")",
"&&",
"!",
"entityManager",
".",
"contains",
"(",
"entity",
")",
")",
"{",
"entityManager",
".",
"persist",
"(",
"entity",
")",
";",
"return",
";",
"}",
"// other cases are update",
"// the simple fact to invoke this method, from a service method annotated with @Transactional,",
"// does the job (assuming the give entity is present in the persistence context)",
"}"
] |
Save or update the given entity E to the repository. Assume that the entity is already present in the persistence context. No merge is done.
@param entity the entity to be saved or updated.
|
[
"Save",
"or",
"update",
"the",
"given",
"entity",
"E",
"to",
"the",
"repository",
".",
"Assume",
"that",
"the",
"entity",
"is",
"already",
"present",
"in",
"the",
"persistence",
"context",
".",
"No",
"merge",
"is",
"done",
"."
] |
61238b967952446d81cc68424a4e809093a77fcf
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java#L553-L571
|
7,702 |
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java
|
GenericRepository.delete
|
@Transactional
public void delete(E entity) {
if (entityManager.contains(entity)) {
entityManager.remove(entity);
} else {
// could be a delete on a transient instance
E entityRef = entityManager.getReference(type, entity.getId());
if (entityRef != null) {
entityManager.remove(entityRef);
} else {
log.warning("Attempt to delete an instance that is not present in the database: " + entity);
}
}
}
|
java
|
@Transactional
public void delete(E entity) {
if (entityManager.contains(entity)) {
entityManager.remove(entity);
} else {
// could be a delete on a transient instance
E entityRef = entityManager.getReference(type, entity.getId());
if (entityRef != null) {
entityManager.remove(entityRef);
} else {
log.warning("Attempt to delete an instance that is not present in the database: " + entity);
}
}
}
|
[
"@",
"Transactional",
"public",
"void",
"delete",
"(",
"E",
"entity",
")",
"{",
"if",
"(",
"entityManager",
".",
"contains",
"(",
"entity",
")",
")",
"{",
"entityManager",
".",
"remove",
"(",
"entity",
")",
";",
"}",
"else",
"{",
"// could be a delete on a transient instance",
"E",
"entityRef",
"=",
"entityManager",
".",
"getReference",
"(",
"type",
",",
"entity",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"entityRef",
"!=",
"null",
")",
"{",
"entityManager",
".",
"remove",
"(",
"entityRef",
")",
";",
"}",
"else",
"{",
"log",
".",
"warning",
"(",
"\"Attempt to delete an instance that is not present in the database: \"",
"+",
"entity",
")",
";",
"}",
"}",
"}"
] |
Delete the given entity E from the repository.
@param entity the entity to be deleted.
|
[
"Delete",
"the",
"given",
"entity",
"E",
"from",
"the",
"repository",
"."
] |
61238b967952446d81cc68424a4e809093a77fcf
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java#L603-L617
|
7,703 |
cchantep/acolyte
|
jdbc-java8/src/main/java/acolyte/jdbc/AcolyteDSL.java
|
AcolyteDSL.connection
|
public static Connection connection(ConnectionHandler h, Property... ps) {
return Driver.connection(h, ps);
}
|
java
|
public static Connection connection(ConnectionHandler h, Property... ps) {
return Driver.connection(h, ps);
}
|
[
"public",
"static",
"Connection",
"connection",
"(",
"ConnectionHandler",
"h",
",",
"Property",
"...",
"ps",
")",
"{",
"return",
"Driver",
".",
"connection",
"(",
"h",
",",
"ps",
")",
";",
"}"
] |
Creates a connection, managed with given handler.
@param h the connection handler
@param ps the connection properties
@return a new Acolyte connection
<pre>
{@code
import acolyte.jdbc.AcolyteDSL;
import static acolyte.jdbc.AcolyteDSL.connection;
import static acolyte.jdbc.AcolyteDSL.prop;
// With connection property to fallback untyped null
connection(handler, prop("acolyte.parameter.untypedNull", "true"));
}
</pre>
|
[
"Creates",
"a",
"connection",
"managed",
"with",
"given",
"handler",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-java8/src/main/java/acolyte/jdbc/AcolyteDSL.java#L99-L101
|
7,704 |
cchantep/acolyte
|
jdbc-java8/src/main/java/acolyte/jdbc/AcolyteDSL.java
|
AcolyteDSL.withQueryResult
|
public static <A> A withQueryResult(QueryResult res,
Function<java.sql.Connection, A> f) {
return f.apply(connection(handleQuery((x, y) -> res)));
}
|
java
|
public static <A> A withQueryResult(QueryResult res,
Function<java.sql.Connection, A> f) {
return f.apply(connection(handleQuery((x, y) -> res)));
}
|
[
"public",
"static",
"<",
"A",
">",
"A",
"withQueryResult",
"(",
"QueryResult",
"res",
",",
"Function",
"<",
"java",
".",
"sql",
".",
"Connection",
",",
"A",
">",
"f",
")",
"{",
"return",
"f",
".",
"apply",
"(",
"connection",
"(",
"handleQuery",
"(",
"(",
"x",
",",
"y",
")",
"->",
"res",
")",
")",
")",
";",
"}"
] |
Executes |f| using a connection accepting only queries,
and answering with |result| to any query.
<pre>
{@code
import static acolyte.jdbc.AcolyteDSL.withQueryResult;
String str = withQueryResult(queryRes, con -> "str");
}
</pre>
|
[
"Executes",
"|f|",
"using",
"a",
"connection",
"accepting",
"only",
"queries",
"and",
"answering",
"with",
"|result|",
"to",
"any",
"query",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-java8/src/main/java/acolyte/jdbc/AcolyteDSL.java#L178-L182
|
7,705 |
cchantep/acolyte
|
studio/src/main/java/acolyte/RowFormatter.java
|
RowFormatter.perform
|
public void perform(final Appender ap)
throws SQLException, UnsupportedEncodingException {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = JDBC.connect(this.jdbcDriver, this.jdbcUrl,
this.user, this.pass);
stmt = con.createStatement();
rs = stmt.executeQuery(this.sql);
appendRows(new ResultIterator(rs), ap,
this.charset, this.formatting, this.cols);
} finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
if (stmt != null) {
try {
stmt.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
if (con != null) {
try {
con.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
} // end of finally
}
|
java
|
public void perform(final Appender ap)
throws SQLException, UnsupportedEncodingException {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = JDBC.connect(this.jdbcDriver, this.jdbcUrl,
this.user, this.pass);
stmt = con.createStatement();
rs = stmt.executeQuery(this.sql);
appendRows(new ResultIterator(rs), ap,
this.charset, this.formatting, this.cols);
} finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
if (stmt != null) {
try {
stmt.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
if (con != null) {
try {
con.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
} // end of finally
}
|
[
"public",
"void",
"perform",
"(",
"final",
"Appender",
"ap",
")",
"throws",
"SQLException",
",",
"UnsupportedEncodingException",
"{",
"Connection",
"con",
"=",
"null",
";",
"Statement",
"stmt",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"con",
"=",
"JDBC",
".",
"connect",
"(",
"this",
".",
"jdbcDriver",
",",
"this",
".",
"jdbcUrl",
",",
"this",
".",
"user",
",",
"this",
".",
"pass",
")",
";",
"stmt",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"this",
".",
"sql",
")",
";",
"appendRows",
"(",
"new",
"ResultIterator",
"(",
"rs",
")",
",",
"ap",
",",
"this",
".",
"charset",
",",
"this",
".",
"formatting",
",",
"this",
".",
"cols",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"rs",
"!=",
"null",
")",
"{",
"try",
"{",
"rs",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}",
"// end of if",
"if",
"(",
"stmt",
"!=",
"null",
")",
"{",
"try",
"{",
"stmt",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}",
"// end of if",
"if",
"(",
"con",
"!=",
"null",
")",
"{",
"try",
"{",
"con",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}",
"// end of if",
"}",
"// end of finally",
"}"
] |
Performs export.
|
[
"Performs",
"export",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/RowFormatter.java#L123-L165
|
7,706 |
cchantep/acolyte
|
studio/src/main/java/acolyte/RowFormatter.java
|
RowFormatter.appendNull
|
static void appendNull(final Appender ap,
final Formatting fmt,
final ColumnType col) {
switch (col) {
case BigDecimal:
ap.append(fmt.noneBigDecimal);
break;
case Boolean:
ap.append(fmt.noneBoolean);
break;
case Byte:
ap.append(fmt.noneByte);
break;
case Short:
ap.append(fmt.noneShort);
break;
case Date:
ap.append(fmt.noneDate);
break;
case Double:
ap.append(fmt.noneDouble);
break;
case Float:
ap.append(fmt.noneFloat);
break;
case Int:
ap.append(fmt.noneInt);
break;
case Long:
ap.append(fmt.noneLong);
break;
case Time:
ap.append(fmt.noneTime);
break;
case Timestamp:
ap.append(fmt.noneTimestamp);
break;
default:
ap.append(fmt.noneString);
break;
} // end of switch
}
|
java
|
static void appendNull(final Appender ap,
final Formatting fmt,
final ColumnType col) {
switch (col) {
case BigDecimal:
ap.append(fmt.noneBigDecimal);
break;
case Boolean:
ap.append(fmt.noneBoolean);
break;
case Byte:
ap.append(fmt.noneByte);
break;
case Short:
ap.append(fmt.noneShort);
break;
case Date:
ap.append(fmt.noneDate);
break;
case Double:
ap.append(fmt.noneDouble);
break;
case Float:
ap.append(fmt.noneFloat);
break;
case Int:
ap.append(fmt.noneInt);
break;
case Long:
ap.append(fmt.noneLong);
break;
case Time:
ap.append(fmt.noneTime);
break;
case Timestamp:
ap.append(fmt.noneTimestamp);
break;
default:
ap.append(fmt.noneString);
break;
} // end of switch
}
|
[
"static",
"void",
"appendNull",
"(",
"final",
"Appender",
"ap",
",",
"final",
"Formatting",
"fmt",
",",
"final",
"ColumnType",
"col",
")",
"{",
"switch",
"(",
"col",
")",
"{",
"case",
"BigDecimal",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneBigDecimal",
")",
";",
"break",
";",
"case",
"Boolean",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneBoolean",
")",
";",
"break",
";",
"case",
"Byte",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneByte",
")",
";",
"break",
";",
"case",
"Short",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneShort",
")",
";",
"break",
";",
"case",
"Date",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneDate",
")",
";",
"break",
";",
"case",
"Double",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneDouble",
")",
";",
"break",
";",
"case",
"Float",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneFloat",
")",
";",
"break",
";",
"case",
"Int",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneInt",
")",
";",
"break",
";",
"case",
"Long",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneLong",
")",
";",
"break",
";",
"case",
"Time",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneTime",
")",
";",
"break",
";",
"case",
"Timestamp",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneTimestamp",
")",
";",
"break",
";",
"default",
":",
"ap",
".",
"append",
"(",
"fmt",
".",
"noneString",
")",
";",
"break",
";",
"}",
"// end of switch",
"}"
] |
Appends a null value.
|
[
"Appends",
"a",
"null",
"value",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/RowFormatter.java#L170-L223
|
7,707 |
cchantep/acolyte
|
studio/src/main/java/acolyte/RowFormatter.java
|
RowFormatter.appendValues
|
static void appendValues(final ResultRow rs,
final Appender ap,
final Charset charset,
final Formatting fmt,
final Iterator<ColumnType> cols,
final int colIndex) {
if (!cols.hasNext()) {
return;
} // end of if
// ---
if (colIndex > 0) {
ap.append(fmt.valueSeparator);
} // end of if
final ColumnType col = cols.next();
if (rs.isNull(colIndex)) {
appendNull(ap, fmt, col);
appendValues(rs, ap, charset, fmt, cols, colIndex+1);
return;
} // end of if
// ---
switch (col) {
case BigDecimal:
ap.append(String.format(fmt.someBigDecimal,
rs.getBigDecimal(colIndex)));
break;
case Boolean:
ap.append(String.format(fmt.someBoolean,
rs.getBoolean(colIndex)));
break;
case Byte:
ap.append(String.format(fmt.someByte,
rs.getByte(colIndex)));
break;
case Short:
ap.append(String.format(fmt.someShort,
rs.getShort(colIndex)));
break;
case Date:
ap.append(String.format(fmt.someDate,
rs.getDate(colIndex).getTime()));
break;
case Double:
ap.append(String.format(fmt.someDouble,
rs.getDouble(colIndex)));
break;
case Float:
ap.append(String.format(fmt.someFloat,
rs.getFloat(colIndex)));
break;
case Int:
ap.append(String.format(fmt.someInt,
rs.getInt(colIndex)));
break;
case Long:
ap.append(String.format(fmt.someLong,
rs.getLong(colIndex)));
break;
case Time:
ap.append(String.format(fmt.someTime,
rs.getTime(colIndex).getTime()));
break;
case Timestamp:
ap.append(String.format(fmt.someTimestamp,
rs.getTimestamp(colIndex).getTime()));
break;
default:
ap.append(String.format(fmt.someString,
new String(rs.getString(colIndex).
getBytes(charset)).
replaceAll("\"", "\\\"")));
break;
} // end of switch
appendValues(rs, ap, charset, fmt, cols, colIndex+1);
}
|
java
|
static void appendValues(final ResultRow rs,
final Appender ap,
final Charset charset,
final Formatting fmt,
final Iterator<ColumnType> cols,
final int colIndex) {
if (!cols.hasNext()) {
return;
} // end of if
// ---
if (colIndex > 0) {
ap.append(fmt.valueSeparator);
} // end of if
final ColumnType col = cols.next();
if (rs.isNull(colIndex)) {
appendNull(ap, fmt, col);
appendValues(rs, ap, charset, fmt, cols, colIndex+1);
return;
} // end of if
// ---
switch (col) {
case BigDecimal:
ap.append(String.format(fmt.someBigDecimal,
rs.getBigDecimal(colIndex)));
break;
case Boolean:
ap.append(String.format(fmt.someBoolean,
rs.getBoolean(colIndex)));
break;
case Byte:
ap.append(String.format(fmt.someByte,
rs.getByte(colIndex)));
break;
case Short:
ap.append(String.format(fmt.someShort,
rs.getShort(colIndex)));
break;
case Date:
ap.append(String.format(fmt.someDate,
rs.getDate(colIndex).getTime()));
break;
case Double:
ap.append(String.format(fmt.someDouble,
rs.getDouble(colIndex)));
break;
case Float:
ap.append(String.format(fmt.someFloat,
rs.getFloat(colIndex)));
break;
case Int:
ap.append(String.format(fmt.someInt,
rs.getInt(colIndex)));
break;
case Long:
ap.append(String.format(fmt.someLong,
rs.getLong(colIndex)));
break;
case Time:
ap.append(String.format(fmt.someTime,
rs.getTime(colIndex).getTime()));
break;
case Timestamp:
ap.append(String.format(fmt.someTimestamp,
rs.getTimestamp(colIndex).getTime()));
break;
default:
ap.append(String.format(fmt.someString,
new String(rs.getString(colIndex).
getBytes(charset)).
replaceAll("\"", "\\\"")));
break;
} // end of switch
appendValues(rs, ap, charset, fmt, cols, colIndex+1);
}
|
[
"static",
"void",
"appendValues",
"(",
"final",
"ResultRow",
"rs",
",",
"final",
"Appender",
"ap",
",",
"final",
"Charset",
"charset",
",",
"final",
"Formatting",
"fmt",
",",
"final",
"Iterator",
"<",
"ColumnType",
">",
"cols",
",",
"final",
"int",
"colIndex",
")",
"{",
"if",
"(",
"!",
"cols",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
";",
"}",
"// end of if",
"// ---",
"if",
"(",
"colIndex",
">",
"0",
")",
"{",
"ap",
".",
"append",
"(",
"fmt",
".",
"valueSeparator",
")",
";",
"}",
"// end of if",
"final",
"ColumnType",
"col",
"=",
"cols",
".",
"next",
"(",
")",
";",
"if",
"(",
"rs",
".",
"isNull",
"(",
"colIndex",
")",
")",
"{",
"appendNull",
"(",
"ap",
",",
"fmt",
",",
"col",
")",
";",
"appendValues",
"(",
"rs",
",",
"ap",
",",
"charset",
",",
"fmt",
",",
"cols",
",",
"colIndex",
"+",
"1",
")",
";",
"return",
";",
"}",
"// end of if",
"// ---",
"switch",
"(",
"col",
")",
"{",
"case",
"BigDecimal",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someBigDecimal",
",",
"rs",
".",
"getBigDecimal",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Boolean",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someBoolean",
",",
"rs",
".",
"getBoolean",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Byte",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someByte",
",",
"rs",
".",
"getByte",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Short",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someShort",
",",
"rs",
".",
"getShort",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Date",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someDate",
",",
"rs",
".",
"getDate",
"(",
"colIndex",
")",
".",
"getTime",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"Double",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someDouble",
",",
"rs",
".",
"getDouble",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Float",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someFloat",
",",
"rs",
".",
"getFloat",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Int",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someInt",
",",
"rs",
".",
"getInt",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Long",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someLong",
",",
"rs",
".",
"getLong",
"(",
"colIndex",
")",
")",
")",
";",
"break",
";",
"case",
"Time",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someTime",
",",
"rs",
".",
"getTime",
"(",
"colIndex",
")",
".",
"getTime",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"Timestamp",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someTimestamp",
",",
"rs",
".",
"getTimestamp",
"(",
"colIndex",
")",
".",
"getTime",
"(",
")",
")",
")",
";",
"break",
";",
"default",
":",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"someString",
",",
"new",
"String",
"(",
"rs",
".",
"getString",
"(",
"colIndex",
")",
".",
"getBytes",
"(",
"charset",
")",
")",
".",
"replaceAll",
"(",
"\"\\\"\"",
",",
"\"\\\\\\\"\"",
")",
")",
")",
";",
"break",
";",
"}",
"// end of switch",
"appendValues",
"(",
"rs",
",",
"ap",
",",
"charset",
",",
"fmt",
",",
"cols",
",",
"colIndex",
"+",
"1",
")",
";",
"}"
] |
Result set values.
|
[
"Result",
"set",
"values",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/RowFormatter.java#L228-L322
|
7,708 |
cchantep/acolyte
|
studio/src/main/java/acolyte/RowFormatter.java
|
RowFormatter.main
|
public static void main(final String[] args) throws Exception {
if (args.length < 4) {
throw new IllegalArgumentException();
} // end of if
// ---
if (new File(args[1]).exists()) { // driver path
final Properties conf = new Properties();
conf.put("jdbc.url", args[0]);
conf.put("jdbc.driverPath", args[1]);
conf.put("db.user", args[2]);
conf.put("db.charset", args[3]);
execWith(sysAppender, conf, args, 4);
return;
} // end of if
// ---
final File config = Studio.preferencesFile();
if (!config.exists()) {
throw new IllegalArgumentException("Cannot find configuration");
} // end of if
// ---
FileInputStream in = null;
try {
in = new FileInputStream(config);
final Properties conf = new Properties();
conf.load(in);
execWith(sysAppender, conf, args, 0);
} catch (Exception e) {
throw new RuntimeException("Fails to load configuration: " +
config.getAbsolutePath(), e);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
} // end of finally
}
|
java
|
public static void main(final String[] args) throws Exception {
if (args.length < 4) {
throw new IllegalArgumentException();
} // end of if
// ---
if (new File(args[1]).exists()) { // driver path
final Properties conf = new Properties();
conf.put("jdbc.url", args[0]);
conf.put("jdbc.driverPath", args[1]);
conf.put("db.user", args[2]);
conf.put("db.charset", args[3]);
execWith(sysAppender, conf, args, 4);
return;
} // end of if
// ---
final File config = Studio.preferencesFile();
if (!config.exists()) {
throw new IllegalArgumentException("Cannot find configuration");
} // end of if
// ---
FileInputStream in = null;
try {
in = new FileInputStream(config);
final Properties conf = new Properties();
conf.load(in);
execWith(sysAppender, conf, args, 0);
} catch (Exception e) {
throw new RuntimeException("Fails to load configuration: " +
config.getAbsolutePath(), e);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
} // end of finally
}
|
[
"public",
"static",
"void",
"main",
"(",
"final",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
"<",
"4",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"// end of if",
"// ---",
"if",
"(",
"new",
"File",
"(",
"args",
"[",
"1",
"]",
")",
".",
"exists",
"(",
")",
")",
"{",
"// driver path",
"final",
"Properties",
"conf",
"=",
"new",
"Properties",
"(",
")",
";",
"conf",
".",
"put",
"(",
"\"jdbc.url\"",
",",
"args",
"[",
"0",
"]",
")",
";",
"conf",
".",
"put",
"(",
"\"jdbc.driverPath\"",
",",
"args",
"[",
"1",
"]",
")",
";",
"conf",
".",
"put",
"(",
"\"db.user\"",
",",
"args",
"[",
"2",
"]",
")",
";",
"conf",
".",
"put",
"(",
"\"db.charset\"",
",",
"args",
"[",
"3",
"]",
")",
";",
"execWith",
"(",
"sysAppender",
",",
"conf",
",",
"args",
",",
"4",
")",
";",
"return",
";",
"}",
"// end of if",
"// ---",
"final",
"File",
"config",
"=",
"Studio",
".",
"preferencesFile",
"(",
")",
";",
"if",
"(",
"!",
"config",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot find configuration\"",
")",
";",
"}",
"// end of if",
"// ---",
"FileInputStream",
"in",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"new",
"FileInputStream",
"(",
"config",
")",
";",
"final",
"Properties",
"conf",
"=",
"new",
"Properties",
"(",
")",
";",
"conf",
".",
"load",
"(",
"in",
")",
";",
"execWith",
"(",
"sysAppender",
",",
"conf",
",",
"args",
",",
"0",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Fails to load configuration: \"",
"+",
"config",
".",
"getAbsolutePath",
"(",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}",
"// end of if",
"}",
"// end of finally",
"}"
] |
CLI runner.
@param args Execution arguments : args[0] - JDBC URL,
args[1] - Path to JAR or JDBC driver,
args[2] - DB user,
args[3] - Encoding,
args[4] - User password,
args[5] - Output format (either "java" or "scala"),
args[6] - SQL statement,
args[7] to args[n] - type(s) of column from 1 to m.
@see ColumnType
|
[
"CLI",
"runner",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/RowFormatter.java#L364-L417
|
7,709 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/AbstractCompositeHandler.java
|
AbstractCompositeHandler.withQueryDetection
|
public T withQueryDetection(final String... pattern) {
if (pattern == null) {
throw new IllegalArgumentException();
} // end of if
// ---
final Pattern[] ps = new Pattern[pattern.length];
int i = 0;
for (final String p : pattern) {
ps[i++] = Pattern.compile(p);
} // end of for
return withQueryDetection(ps);
}
|
java
|
public T withQueryDetection(final String... pattern) {
if (pattern == null) {
throw new IllegalArgumentException();
} // end of if
// ---
final Pattern[] ps = new Pattern[pattern.length];
int i = 0;
for (final String p : pattern) {
ps[i++] = Pattern.compile(p);
} // end of for
return withQueryDetection(ps);
}
|
[
"public",
"T",
"withQueryDetection",
"(",
"final",
"String",
"...",
"pattern",
")",
"{",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"// end of if",
"// ---",
"final",
"Pattern",
"[",
"]",
"ps",
"=",
"new",
"Pattern",
"[",
"pattern",
".",
"length",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"String",
"p",
":",
"pattern",
")",
"{",
"ps",
"[",
"i",
"++",
"]",
"=",
"Pattern",
".",
"compile",
"(",
"p",
")",
";",
"}",
"// end of for",
"return",
"withQueryDetection",
"(",
"ps",
")",
";",
"}"
] |
Returns an new handler based on this one, but including given
query detection |pattern|. If there is already existing pattern,
the new one will be used after.
@param pattern Query detection pattern list
@return New composite handler with given detection pattern
@throws java.util.regex.PatternSyntaxException If |pattern| is invalid
@see #withQueryDetection(java.util.regex.Pattern[])
|
[
"Returns",
"an",
"new",
"handler",
"based",
"on",
"this",
"one",
"but",
"including",
"given",
"query",
"detection",
"|pattern|",
".",
"If",
"there",
"is",
"already",
"existing",
"pattern",
"the",
"new",
"one",
"will",
"be",
"used",
"after",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/AbstractCompositeHandler.java#L119-L134
|
7,710 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/AbstractCompositeHandler.java
|
AbstractCompositeHandler.queryDetectionPattern
|
protected Pattern[] queryDetectionPattern(final Pattern... pattern) {
if (pattern == null) {
throw new IllegalArgumentException();
} // end of if
// ---
if (this.queryDetection == null) {
return pattern;
} // end of if
// ---
final Pattern[] patterns =
new Pattern[this.queryDetection.length + pattern.length];
System.arraycopy(this.queryDetection, 0,
patterns, 0,
this.queryDetection.length);
int i = this.queryDetection.length;
for (final Pattern p : pattern) {
patterns[i++] = p;
} // end of for
return patterns;
}
|
java
|
protected Pattern[] queryDetectionPattern(final Pattern... pattern) {
if (pattern == null) {
throw new IllegalArgumentException();
} // end of if
// ---
if (this.queryDetection == null) {
return pattern;
} // end of if
// ---
final Pattern[] patterns =
new Pattern[this.queryDetection.length + pattern.length];
System.arraycopy(this.queryDetection, 0,
patterns, 0,
this.queryDetection.length);
int i = this.queryDetection.length;
for (final Pattern p : pattern) {
patterns[i++] = p;
} // end of for
return patterns;
}
|
[
"protected",
"Pattern",
"[",
"]",
"queryDetectionPattern",
"(",
"final",
"Pattern",
"...",
"pattern",
")",
"{",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"// end of if",
"// ---",
"if",
"(",
"this",
".",
"queryDetection",
"==",
"null",
")",
"{",
"return",
"pattern",
";",
"}",
"// end of if",
"// ---",
"final",
"Pattern",
"[",
"]",
"patterns",
"=",
"new",
"Pattern",
"[",
"this",
".",
"queryDetection",
".",
"length",
"+",
"pattern",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"queryDetection",
",",
"0",
",",
"patterns",
",",
"0",
",",
"this",
".",
"queryDetection",
".",
"length",
")",
";",
"int",
"i",
"=",
"this",
".",
"queryDetection",
".",
"length",
";",
"for",
"(",
"final",
"Pattern",
"p",
":",
"pattern",
")",
"{",
"patterns",
"[",
"i",
"++",
"]",
"=",
"p",
";",
"}",
"// end of for",
"return",
"patterns",
";",
"}"
] |
Appends given |pattern| to current query detection.
@param pattern the detection pattern
@return the array of detection patterns
@throws IllegalArgumentException if pattern is null
|
[
"Appends",
"given",
"|pattern|",
"to",
"current",
"query",
"detection",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/AbstractCompositeHandler.java#L154-L181
|
7,711 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java
|
ParameterMetaData.Default
|
public static ParameterDef Default(final int sqlType) {
return new ParameterDef(jdbcTypeMappings.get(sqlType),
parameterModeIn,
sqlType,
jdbcTypeNames.get(sqlType),
jdbcTypePrecisions.get(sqlType),
jdbcTypeScales.get(sqlType),
parameterNullableUnknown,
jdbcTypeSigns.get(sqlType));
}
|
java
|
public static ParameterDef Default(final int sqlType) {
return new ParameterDef(jdbcTypeMappings.get(sqlType),
parameterModeIn,
sqlType,
jdbcTypeNames.get(sqlType),
jdbcTypePrecisions.get(sqlType),
jdbcTypeScales.get(sqlType),
parameterNullableUnknown,
jdbcTypeSigns.get(sqlType));
}
|
[
"public",
"static",
"ParameterDef",
"Default",
"(",
"final",
"int",
"sqlType",
")",
"{",
"return",
"new",
"ParameterDef",
"(",
"jdbcTypeMappings",
".",
"get",
"(",
"sqlType",
")",
",",
"parameterModeIn",
",",
"sqlType",
",",
"jdbcTypeNames",
".",
"get",
"(",
"sqlType",
")",
",",
"jdbcTypePrecisions",
".",
"get",
"(",
"sqlType",
")",
",",
"jdbcTypeScales",
".",
"get",
"(",
"sqlType",
")",
",",
"parameterNullableUnknown",
",",
"jdbcTypeSigns",
".",
"get",
"(",
"sqlType",
")",
")",
";",
"}"
] |
Default parameter.
@param sqlType the SQL type for the parameter definition
@return the default definition for a parameter of specified SQL type
|
[
"Default",
"parameter",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java#L185-L194
|
7,712 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java
|
ParameterMetaData.Scaled
|
public static ParameterDef Scaled(final int sqlType, final int scale) {
return new ParameterDef(jdbcTypeMappings.get(sqlType),
parameterModeIn,
sqlType,
jdbcTypeNames.get(sqlType),
jdbcTypePrecisions.get(sqlType),
scale,
parameterNullableUnknown,
jdbcTypeSigns.get(sqlType));
}
|
java
|
public static ParameterDef Scaled(final int sqlType, final int scale) {
return new ParameterDef(jdbcTypeMappings.get(sqlType),
parameterModeIn,
sqlType,
jdbcTypeNames.get(sqlType),
jdbcTypePrecisions.get(sqlType),
scale,
parameterNullableUnknown,
jdbcTypeSigns.get(sqlType));
}
|
[
"public",
"static",
"ParameterDef",
"Scaled",
"(",
"final",
"int",
"sqlType",
",",
"final",
"int",
"scale",
")",
"{",
"return",
"new",
"ParameterDef",
"(",
"jdbcTypeMappings",
".",
"get",
"(",
"sqlType",
")",
",",
"parameterModeIn",
",",
"sqlType",
",",
"jdbcTypeNames",
".",
"get",
"(",
"sqlType",
")",
",",
"jdbcTypePrecisions",
".",
"get",
"(",
"sqlType",
")",
",",
"scale",
",",
"parameterNullableUnknown",
",",
"jdbcTypeSigns",
".",
"get",
"(",
"sqlType",
")",
")",
";",
"}"
] |
Decimal parameter.
@param sqlType the SQL type for the parameter definition
@param scale the scale of the numeric parameter
@return the parameter definition for a number with specified scale
|
[
"Decimal",
"parameter",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java#L203-L213
|
7,713 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java
|
ParameterMetaData.Float
|
public static ParameterDef Float(final float f) {
final BigDecimal bd = new BigDecimal(Float.toString(f));
return Scaled(Types.FLOAT, bd.scale());
}
|
java
|
public static ParameterDef Float(final float f) {
final BigDecimal bd = new BigDecimal(Float.toString(f));
return Scaled(Types.FLOAT, bd.scale());
}
|
[
"public",
"static",
"ParameterDef",
"Float",
"(",
"final",
"float",
"f",
")",
"{",
"final",
"BigDecimal",
"bd",
"=",
"new",
"BigDecimal",
"(",
"Float",
".",
"toString",
"(",
"f",
")",
")",
";",
"return",
"Scaled",
"(",
"Types",
".",
"FLOAT",
",",
"bd",
".",
"scale",
"(",
")",
")",
";",
"}"
] |
Float constructor.
@param f the float value for the parameter
@return Parameter definition for given float value
|
[
"Float",
"constructor",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java#L266-L270
|
7,714 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java
|
ParameterMetaData.Double
|
public static ParameterDef Double(final double d) {
final BigDecimal bd = new BigDecimal(String.format(Locale.US, "%f", d)).
stripTrailingZeros();
return Scaled(Types.DOUBLE, bd.scale());
}
|
java
|
public static ParameterDef Double(final double d) {
final BigDecimal bd = new BigDecimal(String.format(Locale.US, "%f", d)).
stripTrailingZeros();
return Scaled(Types.DOUBLE, bd.scale());
}
|
[
"public",
"static",
"ParameterDef",
"Double",
"(",
"final",
"double",
"d",
")",
"{",
"final",
"BigDecimal",
"bd",
"=",
"new",
"BigDecimal",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"US",
",",
"\"%f\"",
",",
"d",
")",
")",
".",
"stripTrailingZeros",
"(",
")",
";",
"return",
"Scaled",
"(",
"Types",
".",
"DOUBLE",
",",
"bd",
".",
"scale",
"(",
")",
")",
";",
"}"
] |
Double constructor.
@param d the double precision value for the parameter
@return Parameter definition for given double precision value
|
[
"Double",
"constructor",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java#L290-L295
|
7,715 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/RowList.java
|
RowList.resultSet
|
public RowResultSet<R> resultSet(int maxRows) {
if (maxRows <= 0) {
return new RowResultSet<R>(getRows());
} // end of if
return new RowResultSet<R>(getRows().subList(0, maxRows));
}
|
java
|
public RowResultSet<R> resultSet(int maxRows) {
if (maxRows <= 0) {
return new RowResultSet<R>(getRows());
} // end of if
return new RowResultSet<R>(getRows().subList(0, maxRows));
}
|
[
"public",
"RowResultSet",
"<",
"R",
">",
"resultSet",
"(",
"int",
"maxRows",
")",
"{",
"if",
"(",
"maxRows",
"<=",
"0",
")",
"{",
"return",
"new",
"RowResultSet",
"<",
"R",
">",
"(",
"getRows",
"(",
")",
")",
";",
"}",
"// end of if",
"return",
"new",
"RowResultSet",
"<",
"R",
">",
"(",
"getRows",
"(",
")",
".",
"subList",
"(",
"0",
",",
"maxRows",
")",
")",
";",
"}"
] |
Returns result set from these rows.
@param maxRows Limit for the maximum number of rows.
If <= 0 no limit will be set.
If the limit is set and exceeded, the excess rows are silently dropped.
@return ResultSet for this list of rows
|
[
"Returns",
"result",
"set",
"from",
"these",
"rows",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/RowList.java#L84-L90
|
7,716 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/RowList.java
|
RowList.Column
|
public static <T> Column<T> Column(final Class<T> columnClass,
final String name) {
return new Column<T>(columnClass, name);
}
|
java
|
public static <T> Column<T> Column(final Class<T> columnClass,
final String name) {
return new Column<T>(columnClass, name);
}
|
[
"public",
"static",
"<",
"T",
">",
"Column",
"<",
"T",
">",
"Column",
"(",
"final",
"Class",
"<",
"T",
">",
"columnClass",
",",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"Column",
"<",
"T",
">",
"(",
"columnClass",
",",
"name",
")",
";",
"}"
] |
Creates column definition.
@param <T> the type of the column
@param columnClass the class of the column
@param name the column name
@return the column definition
@throws IllegalArgumentException if |columnClass| is null,
or |name| is empty.
|
[
"Creates",
"column",
"definition",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/RowList.java#L237-L241
|
7,717 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/RowList.java
|
RowList.getBlob
|
public java.sql.Blob getBlob(final Object value) throws SQLException {
if (value instanceof java.sql.Blob) return (java.sql.Blob) value;
if (value instanceof byte[]) {
return new SerialBlob((byte[]) value);
}
|
java
|
public java.sql.Blob getBlob(final Object value) throws SQLException {
if (value instanceof java.sql.Blob) return (java.sql.Blob) value;
if (value instanceof byte[]) {
return new SerialBlob((byte[]) value);
}
|
[
"public",
"java",
".",
"sql",
".",
"Blob",
"getBlob",
"(",
"final",
"Object",
"value",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"value",
"instanceof",
"java",
".",
"sql",
".",
"Blob",
")",
"return",
"(",
"java",
".",
"sql",
".",
"Blob",
")",
"value",
";",
"if",
"(",
"value",
"instanceof",
"byte",
"[",
"]",
")",
"{",
"return",
"new",
"SerialBlob",
"(",
"(",
"byte",
"[",
"]",
")",
"value",
")",
";",
"}"
] |
Tries to get BLOB from raw |value|.
@param value the binary value
@return the created BLOB
@throws SQLException if fails to create the BLOB
|
[
"Tries",
"to",
"get",
"BLOB",
"from",
"raw",
"|value|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/RowList.java#L1549-L1554
|
7,718 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/Connection.java
|
Connection.createBlob
|
public Blob createBlob(final byte[] data) throws SQLException {
return new javax.sql.rowset.serial.SerialBlob(data);
}
|
java
|
public Blob createBlob(final byte[] data) throws SQLException {
return new javax.sql.rowset.serial.SerialBlob(data);
}
|
[
"public",
"Blob",
"createBlob",
"(",
"final",
"byte",
"[",
"]",
"data",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"javax",
".",
"sql",
".",
"rowset",
".",
"serial",
".",
"SerialBlob",
"(",
"data",
")",
";",
"}"
] |
Returns a BLOB with given |data|.
@param data the binary data
@return the created BLOB
@throws SQLException if fails to create a BLOB
|
[
"Returns",
"a",
"BLOB",
"with",
"given",
"|data|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/Connection.java#L606-L608
|
7,719 |
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/DefaultLuceneQueryBuilder.java
|
DefaultLuceneQueryBuilder.escapeForFuzzy
|
private String escapeForFuzzy(String word) {
int length = word.length();
char[] tmp = new char[length * 4];
length = ASCIIFoldingFilter.foldToASCII(word.toCharArray(), 0, tmp, 0, length);
return new String(tmp, 0, length);
}
|
java
|
private String escapeForFuzzy(String word) {
int length = word.length();
char[] tmp = new char[length * 4];
length = ASCIIFoldingFilter.foldToASCII(word.toCharArray(), 0, tmp, 0, length);
return new String(tmp, 0, length);
}
|
[
"private",
"String",
"escapeForFuzzy",
"(",
"String",
"word",
")",
"{",
"int",
"length",
"=",
"word",
".",
"length",
"(",
")",
";",
"char",
"[",
"]",
"tmp",
"=",
"new",
"char",
"[",
"length",
"*",
"4",
"]",
";",
"length",
"=",
"ASCIIFoldingFilter",
".",
"foldToASCII",
"(",
"word",
".",
"toCharArray",
"(",
")",
",",
"0",
",",
"tmp",
",",
"0",
",",
"length",
")",
";",
"return",
"new",
"String",
"(",
"tmp",
",",
"0",
",",
"length",
")",
";",
"}"
] |
Apply same filtering as "custom" analyzer. Lowercase is done by QueryParser for fuzzy search.
@param word word
@return word escaped
|
[
"Apply",
"same",
"filtering",
"as",
"custom",
"analyzer",
".",
"Lowercase",
"is",
"done",
"by",
"QueryParser",
"for",
"fuzzy",
"search",
"."
] |
61238b967952446d81cc68424a4e809093a77fcf
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/DefaultLuceneQueryBuilder.java#L163-L168
|
7,720 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.get
|
public String get(String key) throws EtcdClientException {
Preconditions.checkNotNull(key, "key can't be null");
URI uri = buildUriWithKeyAndParams(key, null);
HttpGet httpGet = new HttpGet(uri);
EtcdResult result = syncExecute(httpGet, new int[] {200, 404}, 100);
if (result.isError()) {
if (result.errorCode == 100) {
return null;
}
}
return result.node != null ? result.node.value : null;
}
|
java
|
public String get(String key) throws EtcdClientException {
Preconditions.checkNotNull(key, "key can't be null");
URI uri = buildUriWithKeyAndParams(key, null);
HttpGet httpGet = new HttpGet(uri);
EtcdResult result = syncExecute(httpGet, new int[] {200, 404}, 100);
if (result.isError()) {
if (result.errorCode == 100) {
return null;
}
}
return result.node != null ? result.node.value : null;
}
|
[
"public",
"String",
"get",
"(",
"String",
"key",
")",
"throws",
"EtcdClientException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"key",
",",
"\"key can't be null\"",
")",
";",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"null",
")",
";",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"uri",
")",
";",
"EtcdResult",
"result",
"=",
"syncExecute",
"(",
"httpGet",
",",
"new",
"int",
"[",
"]",
"{",
"200",
",",
"404",
"}",
",",
"100",
")",
";",
"if",
"(",
"result",
".",
"isError",
"(",
")",
")",
"{",
"if",
"(",
"result",
".",
"errorCode",
"==",
"100",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"result",
".",
"node",
"!=",
"null",
"?",
"result",
".",
"node",
".",
"value",
":",
"null",
";",
"}"
] |
Get the value of a key.
@param key the key
@return the corresponding value
|
[
"Get",
"the",
"value",
"of",
"a",
"key",
"."
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L87-L101
|
7,721 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.set
|
public void set(String key, String value, int ttl) throws EtcdClientException {
set(key, value, ttl, null);
}
|
java
|
public void set(String key, String value, int ttl) throws EtcdClientException {
set(key, value, ttl, null);
}
|
[
"public",
"void",
"set",
"(",
"String",
"key",
",",
"String",
"value",
",",
"int",
"ttl",
")",
"throws",
"EtcdClientException",
"{",
"set",
"(",
"key",
",",
"value",
",",
"ttl",
",",
"null",
")",
";",
"}"
] |
Setting the value of a key with optional key TTL
@param key the key
@param value the value
@param ttl optional key TTL
|
[
"Setting",
"the",
"value",
"of",
"a",
"key",
"with",
"optional",
"key",
"TTL"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L118-L120
|
7,722 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.delete
|
public void delete(String key) throws EtcdClientException {
Preconditions.checkNotNull(key);
URI uri = buildUriWithKeyAndParams(key, null);
HttpDelete delete = new HttpDelete(uri);
syncExecute(delete, new int[]{200, 404});
}
|
java
|
public void delete(String key) throws EtcdClientException {
Preconditions.checkNotNull(key);
URI uri = buildUriWithKeyAndParams(key, null);
HttpDelete delete = new HttpDelete(uri);
syncExecute(delete, new int[]{200, 404});
}
|
[
"public",
"void",
"delete",
"(",
"String",
"key",
")",
"throws",
"EtcdClientException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"key",
")",
";",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"null",
")",
";",
"HttpDelete",
"delete",
"=",
"new",
"HttpDelete",
"(",
"uri",
")",
";",
"syncExecute",
"(",
"delete",
",",
"new",
"int",
"[",
"]",
"{",
"200",
",",
"404",
"}",
")",
";",
"}"
] |
Delete a key
@param key the key
// @return operation result
|
[
"Delete",
"a",
"key"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L150-L157
|
7,723 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.listDir
|
public List<EtcdNode> listDir(String key, boolean recursive) throws EtcdClientException {
Preconditions.checkNotNull(key);
Map<String, String> params = new HashMap<String, String>();
if (recursive) {
params.put("recursive", String.valueOf(true));
}
URI uri = buildUriWithKeyAndParams(key, params);
HttpGet httpGet = new HttpGet(uri);
EtcdResult result = syncExecute(httpGet, new int[] {200, 404}, 100);
if (null == result || null == result.node) {
return null;
}
return result.node.nodes;
}
|
java
|
public List<EtcdNode> listDir(String key, boolean recursive) throws EtcdClientException {
Preconditions.checkNotNull(key);
Map<String, String> params = new HashMap<String, String>();
if (recursive) {
params.put("recursive", String.valueOf(true));
}
URI uri = buildUriWithKeyAndParams(key, params);
HttpGet httpGet = new HttpGet(uri);
EtcdResult result = syncExecute(httpGet, new int[] {200, 404}, 100);
if (null == result || null == result.node) {
return null;
}
return result.node.nodes;
}
|
[
"public",
"List",
"<",
"EtcdNode",
">",
"listDir",
"(",
"String",
"key",
",",
"boolean",
"recursive",
")",
"throws",
"EtcdClientException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"key",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"recursive",
")",
"{",
"params",
".",
"put",
"(",
"\"recursive\"",
",",
"String",
".",
"valueOf",
"(",
"true",
")",
")",
";",
"}",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"params",
")",
";",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"uri",
")",
";",
"EtcdResult",
"result",
"=",
"syncExecute",
"(",
"httpGet",
",",
"new",
"int",
"[",
"]",
"{",
"200",
",",
"404",
"}",
",",
"100",
")",
";",
"if",
"(",
"null",
"==",
"result",
"||",
"null",
"==",
"result",
".",
"node",
")",
"{",
"return",
"null",
";",
"}",
"return",
"result",
".",
"node",
".",
"nodes",
";",
"}"
] |
Listing a directory with recursive
@param key the dir key
@param recursive recursive
@return CEtcdNode list
@throws EtcdClientException
|
[
"Listing",
"a",
"directory",
"with",
"recursive"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L217-L234
|
7,724 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.deleteDir
|
public void deleteDir(String key, boolean recursive) throws EtcdClientException {
Preconditions.checkNotNull(key);
Map<String, String> params = new HashMap<String, String>();
if (recursive) {
params.put("recursive", String.valueOf(true));
} else {
params.put("dir", String.valueOf(true));
}
URI uri = buildUriWithKeyAndParams(key, params);
HttpDelete httpDelete = new HttpDelete(uri);
syncExecute(httpDelete, new int[]{200, 403});
}
|
java
|
public void deleteDir(String key, boolean recursive) throws EtcdClientException {
Preconditions.checkNotNull(key);
Map<String, String> params = new HashMap<String, String>();
if (recursive) {
params.put("recursive", String.valueOf(true));
} else {
params.put("dir", String.valueOf(true));
}
URI uri = buildUriWithKeyAndParams(key, params);
HttpDelete httpDelete = new HttpDelete(uri);
syncExecute(httpDelete, new int[]{200, 403});
}
|
[
"public",
"void",
"deleteDir",
"(",
"String",
"key",
",",
"boolean",
"recursive",
")",
"throws",
"EtcdClientException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"key",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"recursive",
")",
"{",
"params",
".",
"put",
"(",
"\"recursive\"",
",",
"String",
".",
"valueOf",
"(",
"true",
")",
")",
";",
"}",
"else",
"{",
"params",
".",
"put",
"(",
"\"dir\"",
",",
"String",
".",
"valueOf",
"(",
"true",
")",
")",
";",
"}",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"params",
")",
";",
"HttpDelete",
"httpDelete",
"=",
"new",
"HttpDelete",
"(",
"uri",
")",
";",
"syncExecute",
"(",
"httpDelete",
",",
"new",
"int",
"[",
"]",
"{",
"200",
",",
"403",
"}",
")",
";",
"}"
] |
Deleting a directory
@param key the dir key
@param recursive set recursive=true if the directory holds keys
// @return operation result
@throws EtcdClientException
|
[
"Deleting",
"a",
"directory"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L243-L257
|
7,725 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.cas
|
public EtcdResult cas(String key, String value, Map<String, String> params) throws EtcdClientException {
List<BasicNameValuePair> data = Lists.newArrayList();
data.add(new BasicNameValuePair("value", value));
return put(key, data, params, new int[] {200, 412}, 101, 105);
}
|
java
|
public EtcdResult cas(String key, String value, Map<String, String> params) throws EtcdClientException {
List<BasicNameValuePair> data = Lists.newArrayList();
data.add(new BasicNameValuePair("value", value));
return put(key, data, params, new int[] {200, 412}, 101, 105);
}
|
[
"public",
"EtcdResult",
"cas",
"(",
"String",
"key",
",",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"EtcdClientException",
"{",
"List",
"<",
"BasicNameValuePair",
">",
"data",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"data",
".",
"add",
"(",
"new",
"BasicNameValuePair",
"(",
"\"value\"",
",",
"value",
")",
")",
";",
"return",
"put",
"(",
"key",
",",
"data",
",",
"params",
",",
"new",
"int",
"[",
"]",
"{",
"200",
",",
"412",
"}",
",",
"101",
",",
"105",
")",
";",
"}"
] |
Atomic Compare-and-Swap
@param key the key
@param value the new value
@param params comparable conditions
@return operation result
@throws EtcdClientException
|
[
"Atomic",
"Compare",
"-",
"and",
"-",
"Swap"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L267-L272
|
7,726 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.cad
|
public EtcdResult cad(String key, Map<String, String> params) throws EtcdClientException {
URI uri = buildUriWithKeyAndParams(key, params);
HttpDelete httpDelete = new HttpDelete(uri);
return syncExecute(httpDelete, new int[] {200, 412}, 101);
}
|
java
|
public EtcdResult cad(String key, Map<String, String> params) throws EtcdClientException {
URI uri = buildUriWithKeyAndParams(key, params);
HttpDelete httpDelete = new HttpDelete(uri);
return syncExecute(httpDelete, new int[] {200, 412}, 101);
}
|
[
"public",
"EtcdResult",
"cad",
"(",
"String",
"key",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"EtcdClientException",
"{",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"params",
")",
";",
"HttpDelete",
"httpDelete",
"=",
"new",
"HttpDelete",
"(",
"uri",
")",
";",
"return",
"syncExecute",
"(",
"httpDelete",
",",
"new",
"int",
"[",
"]",
"{",
"200",
",",
"412",
"}",
",",
"101",
")",
";",
"}"
] |
Atomic Compare-and-Delete
@param key the key
@param params comparable conditions
@return operation result
@throws EtcdClientException
|
[
"Atomic",
"Compare",
"-",
"and",
"-",
"Delete"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L281-L286
|
7,727 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.watch
|
public ListenableFuture<EtcdResult> watch(String key, long index, boolean recursive) {
Map<String, String> params = new HashMap<String, String>();
params.put("wait", String.valueOf(true));
if (index > 0) {
params.put("waitIndex", String.valueOf(index));
}
if (recursive) {
params.put("recursive", String.valueOf(recursive));
}
URI uri = buildUriWithKeyAndParams(key, params);
HttpGet httpGet = new HttpGet(uri);
return asyncExecute(httpGet, new int[] {200});
}
|
java
|
public ListenableFuture<EtcdResult> watch(String key, long index, boolean recursive) {
Map<String, String> params = new HashMap<String, String>();
params.put("wait", String.valueOf(true));
if (index > 0) {
params.put("waitIndex", String.valueOf(index));
}
if (recursive) {
params.put("recursive", String.valueOf(recursive));
}
URI uri = buildUriWithKeyAndParams(key, params);
HttpGet httpGet = new HttpGet(uri);
return asyncExecute(httpGet, new int[] {200});
}
|
[
"public",
"ListenableFuture",
"<",
"EtcdResult",
">",
"watch",
"(",
"String",
"key",
",",
"long",
"index",
",",
"boolean",
"recursive",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"wait\"",
",",
"String",
".",
"valueOf",
"(",
"true",
")",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"params",
".",
"put",
"(",
"\"waitIndex\"",
",",
"String",
".",
"valueOf",
"(",
"index",
")",
")",
";",
"}",
"if",
"(",
"recursive",
")",
"{",
"params",
".",
"put",
"(",
"\"recursive\"",
",",
"String",
".",
"valueOf",
"(",
"recursive",
")",
")",
";",
"}",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"params",
")",
";",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"uri",
")",
";",
"return",
"asyncExecute",
"(",
"httpGet",
",",
"new",
"int",
"[",
"]",
"{",
"200",
"}",
")",
";",
"}"
] |
Watch for a change on a key
@param key the key
@param index the wait index
@param recursive set recursive true if you want to watch for child keys
@return a future result
|
[
"Watch",
"for",
"a",
"change",
"on",
"a",
"key"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L304-L318
|
7,728 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.put
|
private EtcdResult put(String key, List<BasicNameValuePair> data, Map<String, String> params, int[] expectedHttpStatusCodes,
int... expectedErrorCodes) throws EtcdClientException {
URI uri = buildUriWithKeyAndParams(key, params);
HttpPut httpPut = new HttpPut(uri);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(data, Charsets.UTF_8);
httpPut.setEntity(entity);
return syncExecute(httpPut, expectedHttpStatusCodes, expectedErrorCodes);
}
|
java
|
private EtcdResult put(String key, List<BasicNameValuePair> data, Map<String, String> params, int[] expectedHttpStatusCodes,
int... expectedErrorCodes) throws EtcdClientException {
URI uri = buildUriWithKeyAndParams(key, params);
HttpPut httpPut = new HttpPut(uri);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(data, Charsets.UTF_8);
httpPut.setEntity(entity);
return syncExecute(httpPut, expectedHttpStatusCodes, expectedErrorCodes);
}
|
[
"private",
"EtcdResult",
"put",
"(",
"String",
"key",
",",
"List",
"<",
"BasicNameValuePair",
">",
"data",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
",",
"int",
"[",
"]",
"expectedHttpStatusCodes",
",",
"int",
"...",
"expectedErrorCodes",
")",
"throws",
"EtcdClientException",
"{",
"URI",
"uri",
"=",
"buildUriWithKeyAndParams",
"(",
"key",
",",
"params",
")",
";",
"HttpPut",
"httpPut",
"=",
"new",
"HttpPut",
"(",
"uri",
")",
";",
"UrlEncodedFormEntity",
"entity",
"=",
"new",
"UrlEncodedFormEntity",
"(",
"data",
",",
"Charsets",
".",
"UTF_8",
")",
";",
"httpPut",
".",
"setEntity",
"(",
"entity",
")",
";",
"return",
"syncExecute",
"(",
"httpPut",
",",
"expectedHttpStatusCodes",
",",
"expectedErrorCodes",
")",
";",
"}"
] |
The basic put operation
|
[
"The",
"basic",
"put",
"operation"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L335-L344
|
7,729 |
adohe/etcd4j
|
src/main/java/com/xqbase/etcd4j/EtcdClient.java
|
EtcdClient.buildUriWithKeyAndParams
|
private URI buildUriWithKeyAndParams(String key, Map<String, String> params) {
StringBuilder sb = new StringBuilder();
sb.append(URI_PREFIX);
if (key.startsWith("/")) {
key = key.substring(1);
}
for (String token : Splitter.on("/").split(key)) {
sb.append("/").append(urlEscape(token));
}
if (params != null) {
sb.append("?");
for (String str : params.keySet()) {
sb.append(urlEscape(str)).append("=").append(urlEscape(params.get(str)));
sb.append("&");
}
}
String url = sb.toString();
if (url.endsWith("&")) {
url = url.substring(0, url.length() - 1);
}
return baseUri.resolve(url);
}
|
java
|
private URI buildUriWithKeyAndParams(String key, Map<String, String> params) {
StringBuilder sb = new StringBuilder();
sb.append(URI_PREFIX);
if (key.startsWith("/")) {
key = key.substring(1);
}
for (String token : Splitter.on("/").split(key)) {
sb.append("/").append(urlEscape(token));
}
if (params != null) {
sb.append("?");
for (String str : params.keySet()) {
sb.append(urlEscape(str)).append("=").append(urlEscape(params.get(str)));
sb.append("&");
}
}
String url = sb.toString();
if (url.endsWith("&")) {
url = url.substring(0, url.length() - 1);
}
return baseUri.resolve(url);
}
|
[
"private",
"URI",
"buildUriWithKeyAndParams",
"(",
"String",
"key",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"URI_PREFIX",
")",
";",
"if",
"(",
"key",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"key",
"=",
"key",
".",
"substring",
"(",
"1",
")",
";",
"}",
"for",
"(",
"String",
"token",
":",
"Splitter",
".",
"on",
"(",
"\"/\"",
")",
".",
"split",
"(",
"key",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"/\"",
")",
".",
"append",
"(",
"urlEscape",
"(",
"token",
")",
")",
";",
"}",
"if",
"(",
"params",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"\"?\"",
")",
";",
"for",
"(",
"String",
"str",
":",
"params",
".",
"keySet",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"urlEscape",
"(",
"str",
")",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"urlEscape",
"(",
"params",
".",
"get",
"(",
"str",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"&\"",
")",
";",
"}",
"}",
"String",
"url",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"if",
"(",
"url",
".",
"endsWith",
"(",
"\"&\"",
")",
")",
"{",
"url",
"=",
"url",
".",
"substring",
"(",
"0",
",",
"url",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"baseUri",
".",
"resolve",
"(",
"url",
")",
";",
"}"
] |
Build url with key and url params
|
[
"Build",
"url",
"with",
"key",
"and",
"url",
"params"
] |
8d30ae9aa5da32d8e78287d61e69861c63538629
|
https://github.com/adohe/etcd4j/blob/8d30ae9aa5da32d8e78287d61e69861c63538629/src/main/java/com/xqbase/etcd4j/EtcdClient.java#L531-L553
|
7,730 |
cchantep/acolyte
|
studio/src/main/java/acolyte/StudioModel.java
|
StudioModel.setCharset
|
public void setCharset(final Charset charset) {
final Charset old = this.charset;
this.charset = charset;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("charset", old, this.charset);
}
|
java
|
public void setCharset(final Charset charset) {
final Charset old = this.charset;
this.charset = charset;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("charset", old, this.charset);
}
|
[
"public",
"void",
"setCharset",
"(",
"final",
"Charset",
"charset",
")",
"{",
"final",
"Charset",
"old",
"=",
"this",
".",
"charset",
";",
"this",
".",
"charset",
"=",
"charset",
";",
"this",
".",
"connectionConfig",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"this",
".",
"connectionValidated",
"=",
"false",
";",
"this",
".",
"pcs",
".",
"firePropertyChange",
"(",
"\"charset\"",
",",
"old",
",",
"this",
".",
"charset",
")",
";",
"}"
] |
Sets DB |charset|.
@param charset DB charset
@see #getCharset
|
[
"Sets",
"DB",
"|charset|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/StudioModel.java#L99-L107
|
7,731 |
cchantep/acolyte
|
studio/src/main/java/acolyte/StudioModel.java
|
StudioModel.setUser
|
public void setUser(final String user) {
final String old = this.user;
this.user = user;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("user", old, this.user);
}
|
java
|
public void setUser(final String user) {
final String old = this.user;
this.user = user;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("user", old, this.user);
}
|
[
"public",
"void",
"setUser",
"(",
"final",
"String",
"user",
")",
"{",
"final",
"String",
"old",
"=",
"this",
".",
"user",
";",
"this",
".",
"user",
"=",
"user",
";",
"this",
".",
"connectionConfig",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"this",
".",
"connectionValidated",
"=",
"false",
";",
"this",
".",
"pcs",
".",
"firePropertyChange",
"(",
"\"user\"",
",",
"old",
",",
"this",
".",
"user",
")",
";",
"}"
] |
Sets name of DB |user|.
@param user User name
@see #getUser
|
[
"Sets",
"name",
"of",
"DB",
"|user|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/StudioModel.java#L124-L132
|
7,732 |
cchantep/acolyte
|
studio/src/main/java/acolyte/StudioModel.java
|
StudioModel.setUrl
|
public void setUrl(final String url) {
final String old = this.url;
this.url = url;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("url", old, this.url);
}
|
java
|
public void setUrl(final String url) {
final String old = this.url;
this.url = url;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("url", old, this.url);
}
|
[
"public",
"void",
"setUrl",
"(",
"final",
"String",
"url",
")",
"{",
"final",
"String",
"old",
"=",
"this",
".",
"url",
";",
"this",
".",
"url",
"=",
"url",
";",
"this",
".",
"connectionConfig",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"this",
".",
"connectionValidated",
"=",
"false",
";",
"this",
".",
"pcs",
".",
"firePropertyChange",
"(",
"\"url\"",
",",
"old",
",",
"this",
".",
"url",
")",
";",
"}"
] |
Sets JDBC |url|.
@param url JDBC URL
@see #getUrl
|
[
"Sets",
"JDBC",
"|url|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/StudioModel.java#L166-L174
|
7,733 |
cchantep/acolyte
|
studio/src/main/java/acolyte/StudioModel.java
|
StudioModel.setDriver
|
public void setDriver(final Driver driver) {
final Driver old = this.driver;
this.driver = driver;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("driver", old, this.driver);
}
|
java
|
public void setDriver(final Driver driver) {
final Driver old = this.driver;
this.driver = driver;
this.connectionConfig = System.currentTimeMillis();
this.connectionValidated = false;
this.pcs.firePropertyChange("driver", old, this.driver);
}
|
[
"public",
"void",
"setDriver",
"(",
"final",
"Driver",
"driver",
")",
"{",
"final",
"Driver",
"old",
"=",
"this",
".",
"driver",
";",
"this",
".",
"driver",
"=",
"driver",
";",
"this",
".",
"connectionConfig",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"this",
".",
"connectionValidated",
"=",
"false",
";",
"this",
".",
"pcs",
".",
"firePropertyChange",
"(",
"\"driver\"",
",",
"old",
",",
"this",
".",
"driver",
")",
";",
"}"
] |
Sets JDBC |driver|.
@param driver JDBC driver
@see #getDriver
|
[
"Sets",
"JDBC",
"|driver|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/StudioModel.java#L190-L198
|
7,734 |
cchantep/acolyte
|
studio/src/main/java/acolyte/StudioModel.java
|
StudioModel.setConnectionValidated
|
public void setConnectionValidated(final boolean validated) {
final boolean old = this.connectionValidated;
this.connectionValidated = validated;
this.pcs.firePropertyChange("connectionValidated",
old, this.connectionValidated);
}
|
java
|
public void setConnectionValidated(final boolean validated) {
final boolean old = this.connectionValidated;
this.connectionValidated = validated;
this.pcs.firePropertyChange("connectionValidated",
old, this.connectionValidated);
}
|
[
"public",
"void",
"setConnectionValidated",
"(",
"final",
"boolean",
"validated",
")",
"{",
"final",
"boolean",
"old",
"=",
"this",
".",
"connectionValidated",
";",
"this",
".",
"connectionValidated",
"=",
"validated",
";",
"this",
".",
"pcs",
".",
"firePropertyChange",
"(",
"\"connectionValidated\"",
",",
"old",
",",
"this",
".",
"connectionValidated",
")",
";",
"}"
] |
Sets whether connection is |validated|.
@param validated Connection validated?
@see #isConnectionValidated
|
[
"Sets",
"whether",
"connection",
"is",
"|validated|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/StudioModel.java#L214-L221
|
7,735 |
cchantep/acolyte
|
studio/src/main/java/acolyte/StudioModel.java
|
StudioModel.setProcessing
|
public void setProcessing(final boolean processing) {
final boolean old = this.processing;
this.processing = processing;
this.pcs.firePropertyChange("processing", old, this.processing);
}
|
java
|
public void setProcessing(final boolean processing) {
final boolean old = this.processing;
this.processing = processing;
this.pcs.firePropertyChange("processing", old, this.processing);
}
|
[
"public",
"void",
"setProcessing",
"(",
"final",
"boolean",
"processing",
")",
"{",
"final",
"boolean",
"old",
"=",
"this",
".",
"processing",
";",
"this",
".",
"processing",
"=",
"processing",
";",
"this",
".",
"pcs",
".",
"firePropertyChange",
"(",
"\"processing\"",
",",
"old",
",",
"this",
".",
"processing",
")",
";",
"}"
] |
Sets whether is |processing|.
@param processing Is processing?
@see #isProcessing
|
[
"Sets",
"whether",
"is",
"|processing|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/StudioModel.java#L237-L242
|
7,736 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/Driver.java
|
Driver.connect
|
public acolyte.jdbc.Connection connect(final String url,
final Property... info)
throws SQLException {
return connect(url, props(info));
}
|
java
|
public acolyte.jdbc.Connection connect(final String url,
final Property... info)
throws SQLException {
return connect(url, props(info));
}
|
[
"public",
"acolyte",
".",
"jdbc",
".",
"Connection",
"connect",
"(",
"final",
"String",
"url",
",",
"final",
"Property",
"...",
"info",
")",
"throws",
"SQLException",
"{",
"return",
"connect",
"(",
"url",
",",
"props",
"(",
"info",
")",
")",
";",
"}"
] |
Creates a connection to specified |url| with given configuration |info|.
@param url the JDBC URL
@param info the properties for the new connection
@return the configured connection
@throws SQLException if fails to connect
@see #connect(java.lang.String, java.util.Properties)
|
[
"Creates",
"a",
"connection",
"to",
"specified",
"|url|",
"with",
"given",
"configuration",
"|info|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/Driver.java#L99-L104
|
7,737 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/Driver.java
|
Driver.unregister
|
public static ConnectionHandler unregister(final String id) {
if (id == null || id.length() == 0) {
return null; // Not possible
} // end of if
return handlers.remove(id);
}
|
java
|
public static ConnectionHandler unregister(final String id) {
if (id == null || id.length() == 0) {
return null; // Not possible
} // end of if
return handlers.remove(id);
}
|
[
"public",
"static",
"ConnectionHandler",
"unregister",
"(",
"final",
"String",
"id",
")",
"{",
"if",
"(",
"id",
"==",
"null",
"||",
"id",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"// Not possible",
"}",
"// end of if",
"return",
"handlers",
".",
"remove",
"(",
"id",
")",
";",
"}"
] |
Unregisters specified handler.
@param id Handler ID
@return Handler, or null if none
@see #register
|
[
"Unregisters",
"specified",
"handler",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/Driver.java#L308-L314
|
7,738 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/Driver.java
|
Driver.props
|
private static Properties props(final Property[] info) {
final Properties ps = new Properties();
for (final Property p : info) {
ps.put(p.name, p.value);
}
return ps;
}
|
java
|
private static Properties props(final Property[] info) {
final Properties ps = new Properties();
for (final Property p : info) {
ps.put(p.name, p.value);
}
return ps;
}
|
[
"private",
"static",
"Properties",
"props",
"(",
"final",
"Property",
"[",
"]",
"info",
")",
"{",
"final",
"Properties",
"ps",
"=",
"new",
"Properties",
"(",
")",
";",
"for",
"(",
"final",
"Property",
"p",
":",
"info",
")",
"{",
"ps",
".",
"put",
"(",
"p",
".",
"name",
",",
"p",
".",
"value",
")",
";",
"}",
"return",
"ps",
";",
"}"
] |
Returns prepared properties.
@param info the connection information
@return the connection properties
|
[
"Returns",
"prepared",
"properties",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/Driver.java#L322-L330
|
7,739 |
abola/CrawlerPack
|
src/main/java/com/github/abola/crawler/CrawlerPack.java
|
CrawlerPack.addCookie
|
public CrawlerPack addCookie(String name, String value){
if( null == name ) {
log.warn("addCookie: Cookie name null.");
return this;
}
cookies.add( new Cookie("", name, value) );
return this;
}
|
java
|
public CrawlerPack addCookie(String name, String value){
if( null == name ) {
log.warn("addCookie: Cookie name null.");
return this;
}
cookies.add( new Cookie("", name, value) );
return this;
}
|
[
"public",
"CrawlerPack",
"addCookie",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"null",
"==",
"name",
")",
"{",
"log",
".",
"warn",
"(",
"\"addCookie: Cookie name null.\"",
")",
";",
"return",
"this",
";",
"}",
"cookies",
".",
"add",
"(",
"new",
"Cookie",
"(",
"\"\"",
",",
"name",
",",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Creates a cookie with the given name and value.
@param name the cookie name
@param value the cookie value
@return CrawlerPack
|
[
"Creates",
"a",
"cookie",
"with",
"the",
"given",
"name",
"and",
"value",
"."
] |
a7b7703b7fad519994dc04a9c51d90adc11d618f
|
https://github.com/abola/CrawlerPack/blob/a7b7703b7fad519994dc04a9c51d90adc11d618f/src/main/java/com/github/abola/crawler/CrawlerPack.java#L113-L122
|
7,740 |
abola/CrawlerPack
|
src/main/java/com/github/abola/crawler/CrawlerPack.java
|
CrawlerPack.addCookie
|
public CrawlerPack addCookie(String domain, String name, String value,
String path, Date expires, boolean secure) {
if( null == name ) {
log.warn("addCookie: Cookie name null.");
return this;
}
cookies.add(new Cookie(domain, name, value, path, expires, secure));
return this;
}
|
java
|
public CrawlerPack addCookie(String domain, String name, String value,
String path, Date expires, boolean secure) {
if( null == name ) {
log.warn("addCookie: Cookie name null.");
return this;
}
cookies.add(new Cookie(domain, name, value, path, expires, secure));
return this;
}
|
[
"public",
"CrawlerPack",
"addCookie",
"(",
"String",
"domain",
",",
"String",
"name",
",",
"String",
"value",
",",
"String",
"path",
",",
"Date",
"expires",
",",
"boolean",
"secure",
")",
"{",
"if",
"(",
"null",
"==",
"name",
")",
"{",
"log",
".",
"warn",
"(",
"\"addCookie: Cookie name null.\"",
")",
";",
"return",
"this",
";",
"}",
"cookies",
".",
"add",
"(",
"new",
"Cookie",
"(",
"domain",
",",
"name",
",",
"value",
",",
"path",
",",
"expires",
",",
"secure",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Creates a cookie with the given name, value, domain attribute,
path attribute, expiration attribute, and secure attribute
@param name the cookie name
@param value the cookie value
@param domain the domain this cookie can be sent to
@param path the path prefix for which this cookie can be sent
@param expires the {@link Date} at which this cookie expires,
or <tt>null</tt> if the cookie expires at the end
of the session
@param secure if true this cookie can only be sent over secure
connections
|
[
"Creates",
"a",
"cookie",
"with",
"the",
"given",
"name",
"value",
"domain",
"attribute",
"path",
"attribute",
"expiration",
"attribute",
"and",
"secure",
"attribute"
] |
a7b7703b7fad519994dc04a9c51d90adc11d618f
|
https://github.com/abola/CrawlerPack/blob/a7b7703b7fad519994dc04a9c51d90adc11d618f/src/main/java/com/github/abola/crawler/CrawlerPack.java#L139-L148
|
7,741 |
abola/CrawlerPack
|
src/main/java/com/github/abola/crawler/CrawlerPack.java
|
CrawlerPack.getCookies
|
Cookie[] getCookies(String uri){
if( null == cookies || 0 == cookies.size()) return null;
for(Cookie cookie: cookies){
if("".equals(cookie.getDomain())){
String domain = uri.replaceAll("^.*:\\/\\/([^\\/]+)[\\/]?.*$", "$1");
cookie.setDomain(domain);
cookie.setPath("/");
cookie.setExpiryDate(null);
cookie.setSecure(false);
}
}
return cookies.toArray(new Cookie[cookies.size()]);
}
|
java
|
Cookie[] getCookies(String uri){
if( null == cookies || 0 == cookies.size()) return null;
for(Cookie cookie: cookies){
if("".equals(cookie.getDomain())){
String domain = uri.replaceAll("^.*:\\/\\/([^\\/]+)[\\/]?.*$", "$1");
cookie.setDomain(domain);
cookie.setPath("/");
cookie.setExpiryDate(null);
cookie.setSecure(false);
}
}
return cookies.toArray(new Cookie[cookies.size()]);
}
|
[
"Cookie",
"[",
"]",
"getCookies",
"(",
"String",
"uri",
")",
"{",
"if",
"(",
"null",
"==",
"cookies",
"||",
"0",
"==",
"cookies",
".",
"size",
"(",
")",
")",
"return",
"null",
";",
"for",
"(",
"Cookie",
"cookie",
":",
"cookies",
")",
"{",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"cookie",
".",
"getDomain",
"(",
")",
")",
")",
"{",
"String",
"domain",
"=",
"uri",
".",
"replaceAll",
"(",
"\"^.*:\\\\/\\\\/([^\\\\/]+)[\\\\/]?.*$\"",
",",
"\"$1\"",
")",
";",
"cookie",
".",
"setDomain",
"(",
"domain",
")",
";",
"cookie",
".",
"setPath",
"(",
"\"/\"",
")",
";",
"cookie",
".",
"setExpiryDate",
"(",
"null",
")",
";",
"cookie",
".",
"setSecure",
"(",
"false",
")",
";",
"}",
"}",
"return",
"cookies",
".",
"toArray",
"(",
"new",
"Cookie",
"[",
"cookies",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Return a Cookie array
and auto importing domain and path when domain was empty.
@param uri required Apache Common VFS supported file systems and response JSON format content.
@return Cookie[]
|
[
"Return",
"a",
"Cookie",
"array",
"and",
"auto",
"importing",
"domain",
"and",
"path",
"when",
"domain",
"was",
"empty",
"."
] |
a7b7703b7fad519994dc04a9c51d90adc11d618f
|
https://github.com/abola/CrawlerPack/blob/a7b7703b7fad519994dc04a9c51d90adc11d618f/src/main/java/com/github/abola/crawler/CrawlerPack.java#L157-L172
|
7,742 |
abola/CrawlerPack
|
src/main/java/com/github/abola/crawler/CrawlerPack.java
|
CrawlerPack.detectCharset
|
private String detectCharset(byte[] content, Integer offset){
log.debug("detectCharset: offset=" + offset);
// detect failed
if( offset > content.length ) return null;
UniversalDetector detector = new UniversalDetector(null);
detector.handleData(content, offset, content.length - offset > detectBuffer ? detectBuffer : content.length - offset);
detector.dataEnd();
String detectEncoding = detector.getDetectedCharset();
return null==detectEncoding?detectCharset(content,offset+detectBuffer):detectEncoding;
}
|
java
|
private String detectCharset(byte[] content, Integer offset){
log.debug("detectCharset: offset=" + offset);
// detect failed
if( offset > content.length ) return null;
UniversalDetector detector = new UniversalDetector(null);
detector.handleData(content, offset, content.length - offset > detectBuffer ? detectBuffer : content.length - offset);
detector.dataEnd();
String detectEncoding = detector.getDetectedCharset();
return null==detectEncoding?detectCharset(content,offset+detectBuffer):detectEncoding;
}
|
[
"private",
"String",
"detectCharset",
"(",
"byte",
"[",
"]",
"content",
",",
"Integer",
"offset",
")",
"{",
"log",
".",
"debug",
"(",
"\"detectCharset: offset=\"",
"+",
"offset",
")",
";",
"// detect failed",
"if",
"(",
"offset",
">",
"content",
".",
"length",
")",
"return",
"null",
";",
"UniversalDetector",
"detector",
"=",
"new",
"UniversalDetector",
"(",
"null",
")",
";",
"detector",
".",
"handleData",
"(",
"content",
",",
"offset",
",",
"content",
".",
"length",
"-",
"offset",
">",
"detectBuffer",
"?",
"detectBuffer",
":",
"content",
".",
"length",
"-",
"offset",
")",
";",
"detector",
".",
"dataEnd",
"(",
")",
";",
"String",
"detectEncoding",
"=",
"detector",
".",
"getDetectedCharset",
"(",
")",
";",
"return",
"null",
"==",
"detectEncoding",
"?",
"detectCharset",
"(",
"content",
",",
"offset",
"+",
"detectBuffer",
")",
":",
"detectEncoding",
";",
"}"
] |
Detecting real content encoding
@param content
@param offset
@return real charset encoding
|
[
"Detecting",
"real",
"content",
"encoding"
] |
a7b7703b7fad519994dc04a9c51d90adc11d618f
|
https://github.com/abola/CrawlerPack/blob/a7b7703b7fad519994dc04a9c51d90adc11d618f/src/main/java/com/github/abola/crawler/CrawlerPack.java#L404-L417
|
7,743 |
cchantep/acolyte
|
jdbc-java8/src/main/java/acolyte/jdbc/Java8CompositeHandler.java
|
Java8CompositeHandler.withUpdateHandler1
|
public Java8CompositeHandler withUpdateHandler1(CountUpdateHandler h) {
final UpdateHandler uh = new UpdateHandler() {
public UpdateResult apply(String sql, List<Parameter> ps) {
return new UpdateResult(h.apply(sql, ps));
}
};
return withUpdateHandler(uh);
}
|
java
|
public Java8CompositeHandler withUpdateHandler1(CountUpdateHandler h) {
final UpdateHandler uh = new UpdateHandler() {
public UpdateResult apply(String sql, List<Parameter> ps) {
return new UpdateResult(h.apply(sql, ps));
}
};
return withUpdateHandler(uh);
}
|
[
"public",
"Java8CompositeHandler",
"withUpdateHandler1",
"(",
"CountUpdateHandler",
"h",
")",
"{",
"final",
"UpdateHandler",
"uh",
"=",
"new",
"UpdateHandler",
"(",
")",
"{",
"public",
"UpdateResult",
"apply",
"(",
"String",
"sql",
",",
"List",
"<",
"Parameter",
">",
"ps",
")",
"{",
"return",
"new",
"UpdateResult",
"(",
"h",
".",
"apply",
"(",
"sql",
",",
"ps",
")",
")",
";",
"}",
"}",
";",
"return",
"withUpdateHandler",
"(",
"uh",
")",
";",
"}"
] |
Returns handler that delegates update execution to |h| function.
Given function will be used only if executed statement is not detected
as a query by withQueryDetection.
@param h the new update handler
<pre>
{@code
import acolyte.jdbc.UpdateResult;
import acolyte.jdbc.StatementHandler.Parameter;
import static acolyte.jdbc.AcolyteDSL.handleStatement;
handleStatement.withUpdateHandler1((String sql, List<Parameter> ps) -> {
if (sql == "INSERT INTO Country (code, name) VALUES (?, ?)") {
return 1; // update count
} else return 0;
});
}
</pre>
|
[
"Returns",
"handler",
"that",
"delegates",
"update",
"execution",
"to",
"|h|",
"function",
".",
"Given",
"function",
"will",
"be",
"used",
"only",
"if",
"executed",
"statement",
"is",
"not",
"detected",
"as",
"a",
"query",
"by",
"withQueryDetection",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-java8/src/main/java/acolyte/jdbc/Java8CompositeHandler.java#L199-L207
|
7,744 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/CompositeHandler.java
|
CompositeHandler.withQueryHandler
|
public CompositeHandler withQueryHandler(final QueryHandler handler) {
if (handler == null) {
throw new IllegalArgumentException();
} // end of if
// ---
return new CompositeHandler(this.queryDetection,
handler,
this.updateHandler);
}
|
java
|
public CompositeHandler withQueryHandler(final QueryHandler handler) {
if (handler == null) {
throw new IllegalArgumentException();
} // end of if
// ---
return new CompositeHandler(this.queryDetection,
handler,
this.updateHandler);
}
|
[
"public",
"CompositeHandler",
"withQueryHandler",
"(",
"final",
"QueryHandler",
"handler",
")",
"{",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"// end of if",
"// ---",
"return",
"new",
"CompositeHandler",
"(",
"this",
".",
"queryDetection",
",",
"handler",
",",
"this",
".",
"updateHandler",
")",
";",
"}"
] |
Returns a new handler based on this one,
but with given query |handler| appended.
@param handler Query handler
@return a new composite handler with given query handler
@throws IllegalArgumentException if handler is null
|
[
"Returns",
"a",
"new",
"handler",
"based",
"on",
"this",
"one",
"but",
"with",
"given",
"query",
"|handler|",
"appended",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/CompositeHandler.java#L61-L72
|
7,745 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/CompositeHandler.java
|
CompositeHandler.withUpdateHandler
|
public CompositeHandler withUpdateHandler(final UpdateHandler handler) {
if (handler == null) {
throw new IllegalArgumentException();
} // end of if
// ---
return new CompositeHandler(this.queryDetection,
this.queryHandler,
handler);
}
|
java
|
public CompositeHandler withUpdateHandler(final UpdateHandler handler) {
if (handler == null) {
throw new IllegalArgumentException();
} // end of if
// ---
return new CompositeHandler(this.queryDetection,
this.queryHandler,
handler);
}
|
[
"public",
"CompositeHandler",
"withUpdateHandler",
"(",
"final",
"UpdateHandler",
"handler",
")",
"{",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"// end of if",
"// ---",
"return",
"new",
"CompositeHandler",
"(",
"this",
".",
"queryDetection",
",",
"this",
".",
"queryHandler",
",",
"handler",
")",
";",
"}"
] |
Returns a new handler based on this one,
but with given update |handler| appended.
@param handler Update handler
@return a new composite handler with given update handler
@throws IllegalArgumentException if handler is null
|
[
"Returns",
"a",
"new",
"handler",
"based",
"on",
"this",
"one",
"but",
"with",
"given",
"update",
"|handler|",
"appended",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/CompositeHandler.java#L82-L93
|
7,746 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java
|
PreparedStatement.generateKeysResultSet
|
private ResultSet generateKeysResultSet(final UpdateResult res) {
if (this.generatedKeysColumnIndexes == null &&
this.generatedKeysColumnNames == null) {
return res.generatedKeys.resultSet().withStatement(this);
} else if (this.generatedKeysColumnIndexes != null) {
return res.generatedKeys.resultSet().withStatement(this).
withProjection(this.generatedKeysColumnIndexes);
} else {
return res.generatedKeys.resultSet().withStatement(this).
withProjection(this.generatedKeysColumnNames);
}
}
|
java
|
private ResultSet generateKeysResultSet(final UpdateResult res) {
if (this.generatedKeysColumnIndexes == null &&
this.generatedKeysColumnNames == null) {
return res.generatedKeys.resultSet().withStatement(this);
} else if (this.generatedKeysColumnIndexes != null) {
return res.generatedKeys.resultSet().withStatement(this).
withProjection(this.generatedKeysColumnIndexes);
} else {
return res.generatedKeys.resultSet().withStatement(this).
withProjection(this.generatedKeysColumnNames);
}
}
|
[
"private",
"ResultSet",
"generateKeysResultSet",
"(",
"final",
"UpdateResult",
"res",
")",
"{",
"if",
"(",
"this",
".",
"generatedKeysColumnIndexes",
"==",
"null",
"&&",
"this",
".",
"generatedKeysColumnNames",
"==",
"null",
")",
"{",
"return",
"res",
".",
"generatedKeys",
".",
"resultSet",
"(",
")",
".",
"withStatement",
"(",
"this",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"generatedKeysColumnIndexes",
"!=",
"null",
")",
"{",
"return",
"res",
".",
"generatedKeys",
".",
"resultSet",
"(",
")",
".",
"withStatement",
"(",
"this",
")",
".",
"withProjection",
"(",
"this",
".",
"generatedKeysColumnIndexes",
")",
";",
"}",
"else",
"{",
"return",
"res",
".",
"generatedKeys",
".",
"resultSet",
"(",
")",
".",
"withStatement",
"(",
"this",
")",
".",
"withProjection",
"(",
"this",
".",
"generatedKeysColumnNames",
")",
";",
"}",
"}"
] |
Returns the resultset corresponding to the keys generated on update.
|
[
"Returns",
"the",
"resultset",
"corresponding",
"to",
"the",
"keys",
"generated",
"on",
"update",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java#L252-L265
|
7,747 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java
|
PreparedStatement.setDecimal
|
void setDecimal(final int parameterIndex,
final BigDecimal x) throws SQLException {
final ParameterDef def = (x == null) ? Decimal : Decimal(x);
setParam(parameterIndex, def, x);
}
|
java
|
void setDecimal(final int parameterIndex,
final BigDecimal x) throws SQLException {
final ParameterDef def = (x == null) ? Decimal : Decimal(x);
setParam(parameterIndex, def, x);
}
|
[
"void",
"setDecimal",
"(",
"final",
"int",
"parameterIndex",
",",
"final",
"BigDecimal",
"x",
")",
"throws",
"SQLException",
"{",
"final",
"ParameterDef",
"def",
"=",
"(",
"x",
"==",
"null",
")",
"?",
"Decimal",
":",
"Decimal",
"(",
"x",
")",
";",
"setParam",
"(",
"parameterIndex",
",",
"def",
",",
"x",
")",
";",
"}"
] |
Sets parameter as DECIMAL.
@throws SQLException if fails to set the big decimal value
|
[
"Sets",
"parameter",
"as",
"DECIMAL",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java#L993-L999
|
7,748 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java
|
PreparedStatement.normalizeClassName
|
private String normalizeClassName(final Class<?> c) {
if (Blob.class.isAssignableFrom(c)) return "java.sql.Blob";
else if (Array.class.isAssignableFrom(c)) return "java.sql.Array";
return c.getName();
}
|
java
|
private String normalizeClassName(final Class<?> c) {
if (Blob.class.isAssignableFrom(c)) return "java.sql.Blob";
else if (Array.class.isAssignableFrom(c)) return "java.sql.Array";
return c.getName();
}
|
[
"private",
"String",
"normalizeClassName",
"(",
"final",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"if",
"(",
"Blob",
".",
"class",
".",
"isAssignableFrom",
"(",
"c",
")",
")",
"return",
"\"java.sql.Blob\"",
";",
"else",
"if",
"(",
"Array",
".",
"class",
".",
"isAssignableFrom",
"(",
"c",
")",
")",
"return",
"\"java.sql.Array\"",
";",
"return",
"c",
".",
"getName",
"(",
")",
";",
"}"
] |
Normalizes parameter class name.
|
[
"Normalizes",
"parameter",
"class",
"name",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java#L1041-L1046
|
7,749 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java
|
PreparedStatement.createBytes
|
private byte[] createBytes(InputStream stream, long length)
throws SQLException {
ByteArrayOutputStream buff = null;
try {
buff = new ByteArrayOutputStream();
if (length > 0) IOUtils.copyLarge(stream, buff, 0, length);
else IOUtils.copy(stream, buff);
return buff.toByteArray();
} catch (IOException e) {
throw new SQLException("Fails to create BLOB", e);
} finally {
IOUtils.closeQuietly(buff);
} // end of finally
}
|
java
|
private byte[] createBytes(InputStream stream, long length)
throws SQLException {
ByteArrayOutputStream buff = null;
try {
buff = new ByteArrayOutputStream();
if (length > 0) IOUtils.copyLarge(stream, buff, 0, length);
else IOUtils.copy(stream, buff);
return buff.toByteArray();
} catch (IOException e) {
throw new SQLException("Fails to create BLOB", e);
} finally {
IOUtils.closeQuietly(buff);
} // end of finally
}
|
[
"private",
"byte",
"[",
"]",
"createBytes",
"(",
"InputStream",
"stream",
",",
"long",
"length",
")",
"throws",
"SQLException",
"{",
"ByteArrayOutputStream",
"buff",
"=",
"null",
";",
"try",
"{",
"buff",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"if",
"(",
"length",
">",
"0",
")",
"IOUtils",
".",
"copyLarge",
"(",
"stream",
",",
"buff",
",",
"0",
",",
"length",
")",
";",
"else",
"IOUtils",
".",
"copy",
"(",
"stream",
",",
"buff",
")",
";",
"return",
"buff",
".",
"toByteArray",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"Fails to create BLOB\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"buff",
")",
";",
"}",
"// end of finally",
"}"
] |
Creates bytes array from input stream.
@param stream Input stream
@param length
|
[
"Creates",
"bytes",
"array",
"from",
"input",
"stream",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java#L1054-L1071
|
7,750 |
cchantep/acolyte
|
jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java
|
PreparedStatement.createBlob
|
private acolyte.jdbc.Blob createBlob(InputStream stream, long length)
throws SQLException {
final acolyte.jdbc.Blob blob = acolyte.jdbc.Blob.Nil();
blob.setBytes(0L, createBytes(stream, length));
return blob;
}
|
java
|
private acolyte.jdbc.Blob createBlob(InputStream stream, long length)
throws SQLException {
final acolyte.jdbc.Blob blob = acolyte.jdbc.Blob.Nil();
blob.setBytes(0L, createBytes(stream, length));
return blob;
}
|
[
"private",
"acolyte",
".",
"jdbc",
".",
"Blob",
"createBlob",
"(",
"InputStream",
"stream",
",",
"long",
"length",
")",
"throws",
"SQLException",
"{",
"final",
"acolyte",
".",
"jdbc",
".",
"Blob",
"blob",
"=",
"acolyte",
".",
"jdbc",
".",
"Blob",
".",
"Nil",
"(",
")",
";",
"blob",
".",
"setBytes",
"(",
"0L",
",",
"createBytes",
"(",
"stream",
",",
"length",
")",
")",
";",
"return",
"blob",
";",
"}"
] |
Creates BLOB from input stream.
@param stream Input stream
@param length
|
[
"Creates",
"BLOB",
"from",
"input",
"stream",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/PreparedStatement.java#L1079-L1087
|
7,751 |
mygreen/xlsmapper
|
src/main/java/com/gh/mygreen/xlsmapper/xml/AnnotationReader.java
|
AnnotationReader.getAnnotation
|
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(final Class<?> clazz, final Class<A> annClass) throws AnnotationReadException {
if(xmlInfo != null && xmlInfo.containsClassInfo(clazz.getName())) {
final ClassInfo classInfo = xmlInfo.getClassInfo(clazz.getName());
if(classInfo.containsAnnotationInfo(annClass.getName())) {
AnnotationInfo annInfo = classInfo.getAnnotationInfo(annClass.getName());
try {
return (A)annotationBuilder.buildAnnotation(Class.forName(annInfo.getClassName()), annInfo);
} catch (ClassNotFoundException e) {
throw new AnnotationReadException(String.format("not found class '%s'", annInfo.getClassName()), e);
}
}
}
return clazz.getAnnotation(annClass);
}
|
java
|
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(final Class<?> clazz, final Class<A> annClass) throws AnnotationReadException {
if(xmlInfo != null && xmlInfo.containsClassInfo(clazz.getName())) {
final ClassInfo classInfo = xmlInfo.getClassInfo(clazz.getName());
if(classInfo.containsAnnotationInfo(annClass.getName())) {
AnnotationInfo annInfo = classInfo.getAnnotationInfo(annClass.getName());
try {
return (A)annotationBuilder.buildAnnotation(Class.forName(annInfo.getClassName()), annInfo);
} catch (ClassNotFoundException e) {
throw new AnnotationReadException(String.format("not found class '%s'", annInfo.getClassName()), e);
}
}
}
return clazz.getAnnotation(annClass);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"A",
"extends",
"Annotation",
">",
"A",
"getAnnotation",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
",",
"final",
"Class",
"<",
"A",
">",
"annClass",
")",
"throws",
"AnnotationReadException",
"{",
"if",
"(",
"xmlInfo",
"!=",
"null",
"&&",
"xmlInfo",
".",
"containsClassInfo",
"(",
"clazz",
".",
"getName",
"(",
")",
")",
")",
"{",
"final",
"ClassInfo",
"classInfo",
"=",
"xmlInfo",
".",
"getClassInfo",
"(",
"clazz",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"classInfo",
".",
"containsAnnotationInfo",
"(",
"annClass",
".",
"getName",
"(",
")",
")",
")",
"{",
"AnnotationInfo",
"annInfo",
"=",
"classInfo",
".",
"getAnnotationInfo",
"(",
"annClass",
".",
"getName",
"(",
")",
")",
";",
"try",
"{",
"return",
"(",
"A",
")",
"annotationBuilder",
".",
"buildAnnotation",
"(",
"Class",
".",
"forName",
"(",
"annInfo",
".",
"getClassName",
"(",
")",
")",
",",
"annInfo",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"AnnotationReadException",
"(",
"String",
".",
"format",
"(",
"\"not found class '%s'\"",
",",
"annInfo",
".",
"getClassName",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"clazz",
".",
"getAnnotation",
"(",
"annClass",
")",
";",
"}"
] |
Returns a class annotation for the specified type if such an annotation is present, else null.
@param <A> the type of the annotation
@param clazz the target class
@param annClass the Class object corresponding to the annotation type
@return the target class's annotation for the specified annotation type if present on this element, else null
@throws AnnotationReadException
|
[
"Returns",
"a",
"class",
"annotation",
"for",
"the",
"specified",
"type",
"if",
"such",
"an",
"annotation",
"is",
"present",
"else",
"null",
"."
] |
a0c6b25c622e5f3a50b199ef685d2ee46ad5483c
|
https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/xml/AnnotationReader.java#L89-L105
|
7,752 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.studioProcess
|
private <T> SwingWorker<T,T> studioProcess(final int timeout, final Callable<T> c, final UnaryFunction<Callable<T>,T> f) {
final Callable<T> cw = new Callable<T>() {
public T call() {
final FutureTask<T> t = new FutureTask<T>(c);
try {
executor.submit(t);
return t.get(timeout, TimeUnit.SECONDS);
} catch (Exception ex) {
ex.printStackTrace();
} // end of catch
return null;
}
};
return new SwingWorker<T,T>() {
public T doInBackground() throws Exception {
try {
f.apply(cw);
} finally {
model.setProcessing(false);
} // end of finally
return null;
}
};
}
|
java
|
private <T> SwingWorker<T,T> studioProcess(final int timeout, final Callable<T> c, final UnaryFunction<Callable<T>,T> f) {
final Callable<T> cw = new Callable<T>() {
public T call() {
final FutureTask<T> t = new FutureTask<T>(c);
try {
executor.submit(t);
return t.get(timeout, TimeUnit.SECONDS);
} catch (Exception ex) {
ex.printStackTrace();
} // end of catch
return null;
}
};
return new SwingWorker<T,T>() {
public T doInBackground() throws Exception {
try {
f.apply(cw);
} finally {
model.setProcessing(false);
} // end of finally
return null;
}
};
}
|
[
"private",
"<",
"T",
">",
"SwingWorker",
"<",
"T",
",",
"T",
">",
"studioProcess",
"(",
"final",
"int",
"timeout",
",",
"final",
"Callable",
"<",
"T",
">",
"c",
",",
"final",
"UnaryFunction",
"<",
"Callable",
"<",
"T",
">",
",",
"T",
">",
"f",
")",
"{",
"final",
"Callable",
"<",
"T",
">",
"cw",
"=",
"new",
"Callable",
"<",
"T",
">",
"(",
")",
"{",
"public",
"T",
"call",
"(",
")",
"{",
"final",
"FutureTask",
"<",
"T",
">",
"t",
"=",
"new",
"FutureTask",
"<",
"T",
">",
"(",
"c",
")",
";",
"try",
"{",
"executor",
".",
"submit",
"(",
"t",
")",
";",
"return",
"t",
".",
"get",
"(",
"timeout",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"return",
"null",
";",
"}",
"}",
";",
"return",
"new",
"SwingWorker",
"<",
"T",
",",
"T",
">",
"(",
")",
"{",
"public",
"T",
"doInBackground",
"(",
")",
"throws",
"Exception",
"{",
"try",
"{",
"f",
".",
"apply",
"(",
"cw",
")",
";",
"}",
"finally",
"{",
"model",
".",
"setProcessing",
"(",
"false",
")",
";",
"}",
"// end of finally",
"return",
"null",
";",
"}",
"}",
";",
"}"
] |
Studio process.
|
[
"Studio",
"process",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1065-L1093
|
7,753 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.closeKeyStrokes
|
private static final KeyAdapter closeKeyStrokes(final java.awt.Window window) {
return new KeyAdapter() {
public void keyReleased(KeyEvent e) {
final int kc = e.getKeyCode();
if (kc == KeyEvent.VK_ESCAPE ||
kc == KeyEvent.VK_ENTER) {
window.dispose();
}
}
};
}
|
java
|
private static final KeyAdapter closeKeyStrokes(final java.awt.Window window) {
return new KeyAdapter() {
public void keyReleased(KeyEvent e) {
final int kc = e.getKeyCode();
if (kc == KeyEvent.VK_ESCAPE ||
kc == KeyEvent.VK_ENTER) {
window.dispose();
}
}
};
}
|
[
"private",
"static",
"final",
"KeyAdapter",
"closeKeyStrokes",
"(",
"final",
"java",
".",
"awt",
".",
"Window",
"window",
")",
"{",
"return",
"new",
"KeyAdapter",
"(",
")",
"{",
"public",
"void",
"keyReleased",
"(",
"KeyEvent",
"e",
")",
"{",
"final",
"int",
"kc",
"=",
"e",
".",
"getKeyCode",
"(",
")",
";",
"if",
"(",
"kc",
"==",
"KeyEvent",
".",
"VK_ESCAPE",
"||",
"kc",
"==",
"KeyEvent",
".",
"VK_ENTER",
")",
"{",
"window",
".",
"dispose",
"(",
")",
";",
"}",
"}",
"}",
";",
"}"
] |
Listens to key to close a |window|.
|
[
"Listens",
"to",
"key",
"to",
"close",
"a",
"|window|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1098-L1108
|
7,754 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.updateConfig
|
private void updateConfig() {
// JDBC URL
final String u = this.model.getUrl();
final String url = (u != null) ? u.trim() : null;
if (url == null || url.length() == 0) {
this.conf.remove("jdbc.url");
} else {
this.conf.put("jdbc.url", url);
} // end of else
// DB user name
final String n = this.model.getUser();
final String user = (n != null) ? n.trim() : null;
if (user == null || user.length() == 0) {
this.conf.remove("db.user");
} else {
this.conf.put("db.user", user);
} // end of else
// DB charset
final Charset charset = this.model.getCharset();
if (charset == null) {
this.conf.remove("db.charset");
} else {
this.conf.put("db.charset", charset.name());
} // end of else
// Persist configuration
try {
this.saveConf.call();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
}
|
java
|
private void updateConfig() {
// JDBC URL
final String u = this.model.getUrl();
final String url = (u != null) ? u.trim() : null;
if (url == null || url.length() == 0) {
this.conf.remove("jdbc.url");
} else {
this.conf.put("jdbc.url", url);
} // end of else
// DB user name
final String n = this.model.getUser();
final String user = (n != null) ? n.trim() : null;
if (user == null || user.length() == 0) {
this.conf.remove("db.user");
} else {
this.conf.put("db.user", user);
} // end of else
// DB charset
final Charset charset = this.model.getCharset();
if (charset == null) {
this.conf.remove("db.charset");
} else {
this.conf.put("db.charset", charset.name());
} // end of else
// Persist configuration
try {
this.saveConf.call();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
}
|
[
"private",
"void",
"updateConfig",
"(",
")",
"{",
"// JDBC URL",
"final",
"String",
"u",
"=",
"this",
".",
"model",
".",
"getUrl",
"(",
")",
";",
"final",
"String",
"url",
"=",
"(",
"u",
"!=",
"null",
")",
"?",
"u",
".",
"trim",
"(",
")",
":",
"null",
";",
"if",
"(",
"url",
"==",
"null",
"||",
"url",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"this",
".",
"conf",
".",
"remove",
"(",
"\"jdbc.url\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"conf",
".",
"put",
"(",
"\"jdbc.url\"",
",",
"url",
")",
";",
"}",
"// end of else",
"// DB user name",
"final",
"String",
"n",
"=",
"this",
".",
"model",
".",
"getUser",
"(",
")",
";",
"final",
"String",
"user",
"=",
"(",
"n",
"!=",
"null",
")",
"?",
"n",
".",
"trim",
"(",
")",
":",
"null",
";",
"if",
"(",
"user",
"==",
"null",
"||",
"user",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"this",
".",
"conf",
".",
"remove",
"(",
"\"db.user\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"conf",
".",
"put",
"(",
"\"db.user\"",
",",
"user",
")",
";",
"}",
"// end of else",
"// DB charset",
"final",
"Charset",
"charset",
"=",
"this",
".",
"model",
".",
"getCharset",
"(",
")",
";",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"this",
".",
"conf",
".",
"remove",
"(",
"\"db.charset\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"conf",
".",
"put",
"(",
"\"db.charset\"",
",",
"charset",
".",
"name",
"(",
")",
")",
";",
"}",
"// end of else",
"// Persist configuration",
"try",
"{",
"this",
".",
"saveConf",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}"
] |
Updates application configuration.
|
[
"Updates",
"application",
"configuration",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1113-L1149
|
7,755 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.getConnection
|
private Connection getConnection() throws SQLException {
return JDBC.connect(model.getDriver(), model.getUrl(),
model.getUser(), model.getPassword());
}
|
java
|
private Connection getConnection() throws SQLException {
return JDBC.connect(model.getDriver(), model.getUrl(),
model.getUser(), model.getPassword());
}
|
[
"private",
"Connection",
"getConnection",
"(",
")",
"throws",
"SQLException",
"{",
"return",
"JDBC",
".",
"connect",
"(",
"model",
".",
"getDriver",
"(",
")",
",",
"model",
".",
"getUrl",
"(",
")",
",",
"model",
".",
"getUser",
"(",
")",
",",
"model",
".",
"getPassword",
"(",
")",
")",
";",
"}"
] |
Returns JDBC connection for configuration in model.
|
[
"Returns",
"JDBC",
"connection",
"for",
"configuration",
"in",
"model",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1261-L1265
|
7,756 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.tableData
|
private <A> TableData<A> tableData(final ResultSet rs,
final RowFunction<A> f)
throws SQLException {
final ResultSetMetaData meta = rs.getMetaData();
final int c = meta.getColumnCount();
final TableData<A> td = new TableData<A>();
for (int p = 1; p <= c; p++) {
final String n = meta.getColumnLabel(p);
td.columns.add((n == null || "".equals(n)) ? "col" + p : n);
} // end of for
// First row
td.rows.add(f.apply(rs));
// Other row(s)
while (rs.next()) {
td.rows.add(f.apply(rs));
} // end of if
return td;
}
|
java
|
private <A> TableData<A> tableData(final ResultSet rs,
final RowFunction<A> f)
throws SQLException {
final ResultSetMetaData meta = rs.getMetaData();
final int c = meta.getColumnCount();
final TableData<A> td = new TableData<A>();
for (int p = 1; p <= c; p++) {
final String n = meta.getColumnLabel(p);
td.columns.add((n == null || "".equals(n)) ? "col" + p : n);
} // end of for
// First row
td.rows.add(f.apply(rs));
// Other row(s)
while (rs.next()) {
td.rows.add(f.apply(rs));
} // end of if
return td;
}
|
[
"private",
"<",
"A",
">",
"TableData",
"<",
"A",
">",
"tableData",
"(",
"final",
"ResultSet",
"rs",
",",
"final",
"RowFunction",
"<",
"A",
">",
"f",
")",
"throws",
"SQLException",
"{",
"final",
"ResultSetMetaData",
"meta",
"=",
"rs",
".",
"getMetaData",
"(",
")",
";",
"final",
"int",
"c",
"=",
"meta",
".",
"getColumnCount",
"(",
")",
";",
"final",
"TableData",
"<",
"A",
">",
"td",
"=",
"new",
"TableData",
"<",
"A",
">",
"(",
")",
";",
"for",
"(",
"int",
"p",
"=",
"1",
";",
"p",
"<=",
"c",
";",
"p",
"++",
")",
"{",
"final",
"String",
"n",
"=",
"meta",
".",
"getColumnLabel",
"(",
"p",
")",
";",
"td",
".",
"columns",
".",
"add",
"(",
"(",
"n",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"n",
")",
")",
"?",
"\"col\"",
"+",
"p",
":",
"n",
")",
";",
"}",
"// end of for",
"// First row",
"td",
".",
"rows",
".",
"add",
"(",
"f",
".",
"apply",
"(",
"rs",
")",
")",
";",
"// Other row(s)",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"td",
".",
"rows",
".",
"add",
"(",
"f",
".",
"apply",
"(",
"rs",
")",
")",
";",
"}",
"// end of if",
"return",
"td",
";",
"}"
] |
Returns table data from |result| set.
|
[
"Returns",
"table",
"data",
"from",
"|result|",
"set",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1270-L1292
|
7,757 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.setWaitIcon
|
private static ImageIcon setWaitIcon(final JLabel label) {
final ImageIcon ico =
new ImageIcon(Studio.class.getResource("loader.gif"));
label.setIcon(ico);
ico.setImageObserver(label);
return ico;
}
|
java
|
private static ImageIcon setWaitIcon(final JLabel label) {
final ImageIcon ico =
new ImageIcon(Studio.class.getResource("loader.gif"));
label.setIcon(ico);
ico.setImageObserver(label);
return ico;
}
|
[
"private",
"static",
"ImageIcon",
"setWaitIcon",
"(",
"final",
"JLabel",
"label",
")",
"{",
"final",
"ImageIcon",
"ico",
"=",
"new",
"ImageIcon",
"(",
"Studio",
".",
"class",
".",
"getResource",
"(",
"\"loader.gif\"",
")",
")",
";",
"label",
".",
"setIcon",
"(",
"ico",
")",
";",
"ico",
".",
"setImageObserver",
"(",
"label",
")",
";",
"return",
"ico",
";",
"}"
] |
Sets wait icon on |label|.
|
[
"Sets",
"wait",
"icon",
"on",
"|label|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1297-L1305
|
7,758 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.withColRenderers
|
private JTable withColRenderers(final JTable table) {
// Data renderers
final DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
// BigDecimal
table.setDefaultRenderer(BigDecimal.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final BigDecimal bd = (BigDecimal) value;
return dtcr.getTableCellRendererComponent(table, bd.toString(), isSelected, hasFocus, row, column);
}
});
// Boolean
table.setDefaultRenderer(Boolean.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Boolean b = (Boolean) value;
return dtcr.getTableCellRendererComponent(table, Boolean.toString(b), isSelected, hasFocus, row, column);
}
});
// Date
table.setDefaultRenderer(java.sql.Date.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final java.sql.Date d = (java.sql.Date) value;
return dtcr.getTableCellRendererComponent(table, String.format("%tF", d), isSelected, hasFocus, row, column);
}
});
// Time
table.setDefaultRenderer(Time.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Time t = (Time) value;
return dtcr.getTableCellRendererComponent(table, String.format("%tr", t), isSelected, hasFocus, row, column);
}
});
// Timestamp
table.setDefaultRenderer(Timestamp.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Time t = (Time) value;
return dtcr.getTableCellRendererComponent(table, String.format("%tr", t), isSelected, hasFocus, row, column);
}
});
return table;
}
|
java
|
private JTable withColRenderers(final JTable table) {
// Data renderers
final DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
// BigDecimal
table.setDefaultRenderer(BigDecimal.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final BigDecimal bd = (BigDecimal) value;
return dtcr.getTableCellRendererComponent(table, bd.toString(), isSelected, hasFocus, row, column);
}
});
// Boolean
table.setDefaultRenderer(Boolean.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Boolean b = (Boolean) value;
return dtcr.getTableCellRendererComponent(table, Boolean.toString(b), isSelected, hasFocus, row, column);
}
});
// Date
table.setDefaultRenderer(java.sql.Date.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final java.sql.Date d = (java.sql.Date) value;
return dtcr.getTableCellRendererComponent(table, String.format("%tF", d), isSelected, hasFocus, row, column);
}
});
// Time
table.setDefaultRenderer(Time.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Time t = (Time) value;
return dtcr.getTableCellRendererComponent(table, String.format("%tr", t), isSelected, hasFocus, row, column);
}
});
// Timestamp
table.setDefaultRenderer(Timestamp.class, new TableCellRenderer() {
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Time t = (Time) value;
return dtcr.getTableCellRendererComponent(table, String.format("%tr", t), isSelected, hasFocus, row, column);
}
});
return table;
}
|
[
"private",
"JTable",
"withColRenderers",
"(",
"final",
"JTable",
"table",
")",
"{",
"// Data renderers",
"final",
"DefaultTableCellRenderer",
"dtcr",
"=",
"new",
"DefaultTableCellRenderer",
"(",
")",
";",
"// BigDecimal",
"table",
".",
"setDefaultRenderer",
"(",
"BigDecimal",
".",
"class",
",",
"new",
"TableCellRenderer",
"(",
")",
"{",
"public",
"Component",
"getTableCellRendererComponent",
"(",
"final",
"JTable",
"table",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"isSelected",
",",
"final",
"boolean",
"hasFocus",
",",
"final",
"int",
"row",
",",
"final",
"int",
"column",
")",
"{",
"final",
"BigDecimal",
"bd",
"=",
"(",
"BigDecimal",
")",
"value",
";",
"return",
"dtcr",
".",
"getTableCellRendererComponent",
"(",
"table",
",",
"bd",
".",
"toString",
"(",
")",
",",
"isSelected",
",",
"hasFocus",
",",
"row",
",",
"column",
")",
";",
"}",
"}",
")",
";",
"// Boolean",
"table",
".",
"setDefaultRenderer",
"(",
"Boolean",
".",
"class",
",",
"new",
"TableCellRenderer",
"(",
")",
"{",
"public",
"Component",
"getTableCellRendererComponent",
"(",
"final",
"JTable",
"table",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"isSelected",
",",
"final",
"boolean",
"hasFocus",
",",
"final",
"int",
"row",
",",
"final",
"int",
"column",
")",
"{",
"final",
"Boolean",
"b",
"=",
"(",
"Boolean",
")",
"value",
";",
"return",
"dtcr",
".",
"getTableCellRendererComponent",
"(",
"table",
",",
"Boolean",
".",
"toString",
"(",
"b",
")",
",",
"isSelected",
",",
"hasFocus",
",",
"row",
",",
"column",
")",
";",
"}",
"}",
")",
";",
"// Date",
"table",
".",
"setDefaultRenderer",
"(",
"java",
".",
"sql",
".",
"Date",
".",
"class",
",",
"new",
"TableCellRenderer",
"(",
")",
"{",
"public",
"Component",
"getTableCellRendererComponent",
"(",
"final",
"JTable",
"table",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"isSelected",
",",
"final",
"boolean",
"hasFocus",
",",
"final",
"int",
"row",
",",
"final",
"int",
"column",
")",
"{",
"final",
"java",
".",
"sql",
".",
"Date",
"d",
"=",
"(",
"java",
".",
"sql",
".",
"Date",
")",
"value",
";",
"return",
"dtcr",
".",
"getTableCellRendererComponent",
"(",
"table",
",",
"String",
".",
"format",
"(",
"\"%tF\"",
",",
"d",
")",
",",
"isSelected",
",",
"hasFocus",
",",
"row",
",",
"column",
")",
";",
"}",
"}",
")",
";",
"// Time",
"table",
".",
"setDefaultRenderer",
"(",
"Time",
".",
"class",
",",
"new",
"TableCellRenderer",
"(",
")",
"{",
"public",
"Component",
"getTableCellRendererComponent",
"(",
"final",
"JTable",
"table",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"isSelected",
",",
"final",
"boolean",
"hasFocus",
",",
"final",
"int",
"row",
",",
"final",
"int",
"column",
")",
"{",
"final",
"Time",
"t",
"=",
"(",
"Time",
")",
"value",
";",
"return",
"dtcr",
".",
"getTableCellRendererComponent",
"(",
"table",
",",
"String",
".",
"format",
"(",
"\"%tr\"",
",",
"t",
")",
",",
"isSelected",
",",
"hasFocus",
",",
"row",
",",
"column",
")",
";",
"}",
"}",
")",
";",
"// Timestamp",
"table",
".",
"setDefaultRenderer",
"(",
"Timestamp",
".",
"class",
",",
"new",
"TableCellRenderer",
"(",
")",
"{",
"public",
"Component",
"getTableCellRendererComponent",
"(",
"final",
"JTable",
"table",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"isSelected",
",",
"final",
"boolean",
"hasFocus",
",",
"final",
"int",
"row",
",",
"final",
"int",
"column",
")",
"{",
"final",
"Time",
"t",
"=",
"(",
"Time",
")",
"value",
";",
"return",
"dtcr",
".",
"getTableCellRendererComponent",
"(",
"table",
",",
"String",
".",
"format",
"(",
"\"%tr\"",
",",
"t",
")",
",",
"isSelected",
",",
"hasFocus",
",",
"row",
",",
"column",
")",
";",
"}",
"}",
")",
";",
"return",
"table",
";",
"}"
] |
Returns table with column renderers.
|
[
"Returns",
"table",
"with",
"column",
"renderers",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1310-L1365
|
7,759 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.chooseDriver
|
public void chooseDriver(final JFrame frm, final JTextField field) {
final JFileChooser chooser = new JFileChooser(new File("."));
for (final FileFilter ff : chooser.getChoosableFileFilters()) {
chooser.removeChoosableFileFilter(ff); // clean choosable filters
} // end of for
chooser.setFileHidingEnabled(false);
chooser.setDialogTitle("Chooser JDBC driver");
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(new JDBCDriverFileFilter());
final int choice = chooser.showOpenDialog(frm);
if (choice != JFileChooser.APPROVE_OPTION) {
return;
} // end of if
// ---
final File driverFile = chooser.getSelectedFile();
final String driverPath = driverFile.getAbsolutePath();
field.setForeground(Color.BLACK);
field.setText(driverPath);
try {
model.setDriver(JDBC.loadDriver(driverFile));
// !! Side-effect
conf.put("jdbc.driverPath", driverPath);
updateConfig();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
}
|
java
|
public void chooseDriver(final JFrame frm, final JTextField field) {
final JFileChooser chooser = new JFileChooser(new File("."));
for (final FileFilter ff : chooser.getChoosableFileFilters()) {
chooser.removeChoosableFileFilter(ff); // clean choosable filters
} // end of for
chooser.setFileHidingEnabled(false);
chooser.setDialogTitle("Chooser JDBC driver");
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(new JDBCDriverFileFilter());
final int choice = chooser.showOpenDialog(frm);
if (choice != JFileChooser.APPROVE_OPTION) {
return;
} // end of if
// ---
final File driverFile = chooser.getSelectedFile();
final String driverPath = driverFile.getAbsolutePath();
field.setForeground(Color.BLACK);
field.setText(driverPath);
try {
model.setDriver(JDBC.loadDriver(driverFile));
// !! Side-effect
conf.put("jdbc.driverPath", driverPath);
updateConfig();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
}
|
[
"public",
"void",
"chooseDriver",
"(",
"final",
"JFrame",
"frm",
",",
"final",
"JTextField",
"field",
")",
"{",
"final",
"JFileChooser",
"chooser",
"=",
"new",
"JFileChooser",
"(",
"new",
"File",
"(",
"\".\"",
")",
")",
";",
"for",
"(",
"final",
"FileFilter",
"ff",
":",
"chooser",
".",
"getChoosableFileFilters",
"(",
")",
")",
"{",
"chooser",
".",
"removeChoosableFileFilter",
"(",
"ff",
")",
";",
"// clean choosable filters",
"}",
"// end of for",
"chooser",
".",
"setFileHidingEnabled",
"(",
"false",
")",
";",
"chooser",
".",
"setDialogTitle",
"(",
"\"Chooser JDBC driver\"",
")",
";",
"chooser",
".",
"setMultiSelectionEnabled",
"(",
"false",
")",
";",
"chooser",
".",
"setFileFilter",
"(",
"new",
"JDBCDriverFileFilter",
"(",
")",
")",
";",
"final",
"int",
"choice",
"=",
"chooser",
".",
"showOpenDialog",
"(",
"frm",
")",
";",
"if",
"(",
"choice",
"!=",
"JFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"return",
";",
"}",
"// end of if",
"// ---",
"final",
"File",
"driverFile",
"=",
"chooser",
".",
"getSelectedFile",
"(",
")",
";",
"final",
"String",
"driverPath",
"=",
"driverFile",
".",
"getAbsolutePath",
"(",
")",
";",
"field",
".",
"setForeground",
"(",
"Color",
".",
"BLACK",
")",
";",
"field",
".",
"setText",
"(",
"driverPath",
")",
";",
"try",
"{",
"model",
".",
"setDriver",
"(",
"JDBC",
".",
"loadDriver",
"(",
"driverFile",
")",
")",
";",
"// !! Side-effect",
"conf",
".",
"put",
"(",
"\"jdbc.driverPath\"",
",",
"driverPath",
")",
";",
"updateConfig",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}"
] |
Chooses a JDBC driver.
|
[
"Chooses",
"a",
"JDBC",
"driver",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1370-L1404
|
7,760 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Studio.java
|
Studio.displayRows
|
private static void displayRows(final JFrame frm, final Vector<Map.Entry<String,ColumnType>> cols, final Vector<Vector<Object>> data, final Charset charset, final Formatting fmt, final Callable<Void> end) {
final UnaryFunction<Document,Callable<Void>> f =
new UnaryFunction<Document,Callable<Void>>() {
public Callable<Void> apply(final Document doc) {
final DocumentAppender ap = new DocumentAppender(doc);
// Column definitions
final ArrayList<String> cnames = new ArrayList<String>();
final ArrayList<ColumnType> ctypes =
new ArrayList<ColumnType>();
final int c = cols.size();
ap.append(fmt.imports);
ap.append("\r\n\r\nRowLists.rowList" + c + "(");
int i = 0;
for (final Map.Entry<String,ColumnType> e : cols) {
final String name = e.getKey();
final ColumnType type = e.getValue();
cnames.add(name);
ctypes.add(type);
if (i++ > 0) {
ap.append(", ");
} // end of if
final String tname = (fmt.typeMap.containsKey(type))
? fmt.typeMap.get(type) : "String";
ap.append(String.format(fmt.colDef, tname, name));
} // end of while
ap.append(")\r\n");
// --
return new Callable<Void>() {
public Void call() {
RowFormatter.
appendRows(new VectorIterator(data), ap, charset,
fmt, ctypes);
return null;
}
};
} // end of apply
}; // end of f
createConvertDialog(frm, fmt, f, end);
}
|
java
|
private static void displayRows(final JFrame frm, final Vector<Map.Entry<String,ColumnType>> cols, final Vector<Vector<Object>> data, final Charset charset, final Formatting fmt, final Callable<Void> end) {
final UnaryFunction<Document,Callable<Void>> f =
new UnaryFunction<Document,Callable<Void>>() {
public Callable<Void> apply(final Document doc) {
final DocumentAppender ap = new DocumentAppender(doc);
// Column definitions
final ArrayList<String> cnames = new ArrayList<String>();
final ArrayList<ColumnType> ctypes =
new ArrayList<ColumnType>();
final int c = cols.size();
ap.append(fmt.imports);
ap.append("\r\n\r\nRowLists.rowList" + c + "(");
int i = 0;
for (final Map.Entry<String,ColumnType> e : cols) {
final String name = e.getKey();
final ColumnType type = e.getValue();
cnames.add(name);
ctypes.add(type);
if (i++ > 0) {
ap.append(", ");
} // end of if
final String tname = (fmt.typeMap.containsKey(type))
? fmt.typeMap.get(type) : "String";
ap.append(String.format(fmt.colDef, tname, name));
} // end of while
ap.append(")\r\n");
// --
return new Callable<Void>() {
public Void call() {
RowFormatter.
appendRows(new VectorIterator(data), ap, charset,
fmt, ctypes);
return null;
}
};
} // end of apply
}; // end of f
createConvertDialog(frm, fmt, f, end);
}
|
[
"private",
"static",
"void",
"displayRows",
"(",
"final",
"JFrame",
"frm",
",",
"final",
"Vector",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"ColumnType",
">",
">",
"cols",
",",
"final",
"Vector",
"<",
"Vector",
"<",
"Object",
">",
">",
"data",
",",
"final",
"Charset",
"charset",
",",
"final",
"Formatting",
"fmt",
",",
"final",
"Callable",
"<",
"Void",
">",
"end",
")",
"{",
"final",
"UnaryFunction",
"<",
"Document",
",",
"Callable",
"<",
"Void",
">",
">",
"f",
"=",
"new",
"UnaryFunction",
"<",
"Document",
",",
"Callable",
"<",
"Void",
">",
">",
"(",
")",
"{",
"public",
"Callable",
"<",
"Void",
">",
"apply",
"(",
"final",
"Document",
"doc",
")",
"{",
"final",
"DocumentAppender",
"ap",
"=",
"new",
"DocumentAppender",
"(",
"doc",
")",
";",
"// Column definitions",
"final",
"ArrayList",
"<",
"String",
">",
"cnames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"final",
"ArrayList",
"<",
"ColumnType",
">",
"ctypes",
"=",
"new",
"ArrayList",
"<",
"ColumnType",
">",
"(",
")",
";",
"final",
"int",
"c",
"=",
"cols",
".",
"size",
"(",
")",
";",
"ap",
".",
"append",
"(",
"fmt",
".",
"imports",
")",
";",
"ap",
".",
"append",
"(",
"\"\\r\\n\\r\\nRowLists.rowList\"",
"+",
"c",
"+",
"\"(\"",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"ColumnType",
">",
"e",
":",
"cols",
")",
"{",
"final",
"String",
"name",
"=",
"e",
".",
"getKey",
"(",
")",
";",
"final",
"ColumnType",
"type",
"=",
"e",
".",
"getValue",
"(",
")",
";",
"cnames",
".",
"add",
"(",
"name",
")",
";",
"ctypes",
".",
"add",
"(",
"type",
")",
";",
"if",
"(",
"i",
"++",
">",
"0",
")",
"{",
"ap",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"// end of if",
"final",
"String",
"tname",
"=",
"(",
"fmt",
".",
"typeMap",
".",
"containsKey",
"(",
"type",
")",
")",
"?",
"fmt",
".",
"typeMap",
".",
"get",
"(",
"type",
")",
":",
"\"String\"",
";",
"ap",
".",
"append",
"(",
"String",
".",
"format",
"(",
"fmt",
".",
"colDef",
",",
"tname",
",",
"name",
")",
")",
";",
"}",
"// end of while",
"ap",
".",
"append",
"(",
"\")\\r\\n\"",
")",
";",
"// --",
"return",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"public",
"Void",
"call",
"(",
")",
"{",
"RowFormatter",
".",
"appendRows",
"(",
"new",
"VectorIterator",
"(",
"data",
")",
",",
"ap",
",",
"charset",
",",
"fmt",
",",
"ctypes",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"}",
"// end of apply",
"}",
";",
"// end of f",
"createConvertDialog",
"(",
"frm",
",",
"fmt",
",",
"f",
",",
"end",
")",
";",
"}"
] |
Displays formatted rows.
|
[
"Displays",
"formatted",
"rows",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Studio.java#L1514-L1565
|
7,761 |
cchantep/acolyte
|
studio/src/main/java/acolyte/Configuration.java
|
Configuration.loadConfig
|
protected static void loadConfig(final Properties config,
final File f) {
InputStreamReader r = null;
try {
final FileInputStream in = new FileInputStream(f);
r = new InputStreamReader(in, "UTF-8");
config.load(r);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (r != null) {
try {
r.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
} // end of finally
}
|
java
|
protected static void loadConfig(final Properties config,
final File f) {
InputStreamReader r = null;
try {
final FileInputStream in = new FileInputStream(f);
r = new InputStreamReader(in, "UTF-8");
config.load(r);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (r != null) {
try {
r.close();
} catch (Exception e) {
e.printStackTrace();
} // end of catch
} // end of if
} // end of finally
}
|
[
"protected",
"static",
"void",
"loadConfig",
"(",
"final",
"Properties",
"config",
",",
"final",
"File",
"f",
")",
"{",
"InputStreamReader",
"r",
"=",
"null",
";",
"try",
"{",
"final",
"FileInputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"f",
")",
";",
"r",
"=",
"new",
"InputStreamReader",
"(",
"in",
",",
"\"UTF-8\"",
")",
";",
"config",
".",
"load",
"(",
"r",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"r",
"!=",
"null",
")",
"{",
"try",
"{",
"r",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// end of catch",
"}",
"// end of if",
"}",
"// end of finally",
"}"
] |
Loads configuration from |file|.
@param config Configuration container
@param f File to be loaded
|
[
"Loads",
"configuration",
"from",
"|file|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/Configuration.java#L22-L42
|
7,762 |
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/MetamodelUtil.java
|
MetamodelUtil.getCascades
|
public Collection<CascadeType> getCascades(PluralAttribute<?, ?, ?> attribute) {
if (attribute.getJavaMember() instanceof AccessibleObject) {
AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
OneToMany oneToMany = accessibleObject.getAnnotation(OneToMany.class);
if (oneToMany != null) {
return newArrayList(oneToMany.cascade());
}
ManyToMany manyToMany = accessibleObject.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
return newArrayList(manyToMany.cascade());
}
}
return newArrayList();
}
|
java
|
public Collection<CascadeType> getCascades(PluralAttribute<?, ?, ?> attribute) {
if (attribute.getJavaMember() instanceof AccessibleObject) {
AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
OneToMany oneToMany = accessibleObject.getAnnotation(OneToMany.class);
if (oneToMany != null) {
return newArrayList(oneToMany.cascade());
}
ManyToMany manyToMany = accessibleObject.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
return newArrayList(manyToMany.cascade());
}
}
return newArrayList();
}
|
[
"public",
"Collection",
"<",
"CascadeType",
">",
"getCascades",
"(",
"PluralAttribute",
"<",
"?",
",",
"?",
",",
"?",
">",
"attribute",
")",
"{",
"if",
"(",
"attribute",
".",
"getJavaMember",
"(",
")",
"instanceof",
"AccessibleObject",
")",
"{",
"AccessibleObject",
"accessibleObject",
"=",
"(",
"AccessibleObject",
")",
"attribute",
".",
"getJavaMember",
"(",
")",
";",
"OneToMany",
"oneToMany",
"=",
"accessibleObject",
".",
"getAnnotation",
"(",
"OneToMany",
".",
"class",
")",
";",
"if",
"(",
"oneToMany",
"!=",
"null",
")",
"{",
"return",
"newArrayList",
"(",
"oneToMany",
".",
"cascade",
"(",
")",
")",
";",
"}",
"ManyToMany",
"manyToMany",
"=",
"accessibleObject",
".",
"getAnnotation",
"(",
"ManyToMany",
".",
"class",
")",
";",
"if",
"(",
"manyToMany",
"!=",
"null",
")",
"{",
"return",
"newArrayList",
"(",
"manyToMany",
".",
"cascade",
"(",
")",
")",
";",
"}",
"}",
"return",
"newArrayList",
"(",
")",
";",
"}"
] |
Retrieves cascade from metamodel attribute
@param attribute given pluaral attribute
@return an empty collection if no jpa relation annotation can be found.
|
[
"Retrieves",
"cascade",
"from",
"metamodel",
"attribute"
] |
61238b967952446d81cc68424a4e809093a77fcf
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/MetamodelUtil.java#L107-L120
|
7,763 |
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/MetamodelUtil.java
|
MetamodelUtil.getCascades
|
public Collection<CascadeType> getCascades(SingularAttribute<?, ?> attribute) {
if (attribute.getJavaMember() instanceof AccessibleObject) {
AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
OneToOne oneToOne = accessibleObject.getAnnotation(OneToOne.class);
if (oneToOne != null) {
return newArrayList(oneToOne.cascade());
}
ManyToOne manyToOne = accessibleObject.getAnnotation(ManyToOne.class);
if (manyToOne != null) {
return newArrayList(manyToOne.cascade());
}
}
return newArrayList();
}
|
java
|
public Collection<CascadeType> getCascades(SingularAttribute<?, ?> attribute) {
if (attribute.getJavaMember() instanceof AccessibleObject) {
AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
OneToOne oneToOne = accessibleObject.getAnnotation(OneToOne.class);
if (oneToOne != null) {
return newArrayList(oneToOne.cascade());
}
ManyToOne manyToOne = accessibleObject.getAnnotation(ManyToOne.class);
if (manyToOne != null) {
return newArrayList(manyToOne.cascade());
}
}
return newArrayList();
}
|
[
"public",
"Collection",
"<",
"CascadeType",
">",
"getCascades",
"(",
"SingularAttribute",
"<",
"?",
",",
"?",
">",
"attribute",
")",
"{",
"if",
"(",
"attribute",
".",
"getJavaMember",
"(",
")",
"instanceof",
"AccessibleObject",
")",
"{",
"AccessibleObject",
"accessibleObject",
"=",
"(",
"AccessibleObject",
")",
"attribute",
".",
"getJavaMember",
"(",
")",
";",
"OneToOne",
"oneToOne",
"=",
"accessibleObject",
".",
"getAnnotation",
"(",
"OneToOne",
".",
"class",
")",
";",
"if",
"(",
"oneToOne",
"!=",
"null",
")",
"{",
"return",
"newArrayList",
"(",
"oneToOne",
".",
"cascade",
"(",
")",
")",
";",
"}",
"ManyToOne",
"manyToOne",
"=",
"accessibleObject",
".",
"getAnnotation",
"(",
"ManyToOne",
".",
"class",
")",
";",
"if",
"(",
"manyToOne",
"!=",
"null",
")",
"{",
"return",
"newArrayList",
"(",
"manyToOne",
".",
"cascade",
"(",
")",
")",
";",
"}",
"}",
"return",
"newArrayList",
"(",
")",
";",
"}"
] |
Retrieves cascade from metamodel attribute on a xToMany relation.
@param attribute given singular attribute
@return an empty collection if no jpa relation annotation can be found.
|
[
"Retrieves",
"cascade",
"from",
"metamodel",
"attribute",
"on",
"a",
"xToMany",
"relation",
"."
] |
61238b967952446d81cc68424a4e809093a77fcf
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/MetamodelUtil.java#L128-L141
|
7,764 |
cchantep/acolyte
|
studio/src/main/java/acolyte/JDBC.java
|
JDBC.connect
|
public static Connection connect(final Driver driver, final String url,
final String user, final String pass)
throws SQLException {
final Properties props = new Properties();
props.put("user", user);
props.put("password", pass);
return driver.connect(url, props);
}
|
java
|
public static Connection connect(final Driver driver, final String url,
final String user, final String pass)
throws SQLException {
final Properties props = new Properties();
props.put("user", user);
props.put("password", pass);
return driver.connect(url, props);
}
|
[
"public",
"static",
"Connection",
"connect",
"(",
"final",
"Driver",
"driver",
",",
"final",
"String",
"url",
",",
"final",
"String",
"user",
",",
"final",
"String",
"pass",
")",
"throws",
"SQLException",
"{",
"final",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
".",
"put",
"(",
"\"user\"",
",",
"user",
")",
";",
"props",
".",
"put",
"(",
"\"password\"",
",",
"pass",
")",
";",
"return",
"driver",
".",
"connect",
"(",
"url",
",",
"props",
")",
";",
"}"
] |
Returns connection using given |driver|.
@param driver JDBC driver
@param url JDBC url
@param user DB user name
@param pass Password for DB user
|
[
"Returns",
"connection",
"using",
"given",
"|driver|",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/JDBC.java#L77-L87
|
7,765 |
cchantep/acolyte
|
studio/src/main/java/acolyte/JDBC.java
|
JDBC.getObject
|
public static Object getObject(final ResultSet rs,
final String name,
final ColumnType type) throws SQLException {
switch (type) {
case BigDecimal: return rs.getBigDecimal(name);
case Boolean: return rs.getBoolean(name);
case Byte: return rs.getByte(name);
case Short: return rs.getShort(name);
case Date: return rs.getDate(name);
case Double: return rs.getDouble(name);
case Float: return rs.getFloat(name);
case Int: return rs.getInt(name);
case Long: return rs.getLong(name);
case Time: return rs.getTime(name);
case Timestamp: return rs.getTimestamp(name);
default: return rs.getString(name);
}
}
|
java
|
public static Object getObject(final ResultSet rs,
final String name,
final ColumnType type) throws SQLException {
switch (type) {
case BigDecimal: return rs.getBigDecimal(name);
case Boolean: return rs.getBoolean(name);
case Byte: return rs.getByte(name);
case Short: return rs.getShort(name);
case Date: return rs.getDate(name);
case Double: return rs.getDouble(name);
case Float: return rs.getFloat(name);
case Int: return rs.getInt(name);
case Long: return rs.getLong(name);
case Time: return rs.getTime(name);
case Timestamp: return rs.getTimestamp(name);
default: return rs.getString(name);
}
}
|
[
"public",
"static",
"Object",
"getObject",
"(",
"final",
"ResultSet",
"rs",
",",
"final",
"String",
"name",
",",
"final",
"ColumnType",
"type",
")",
"throws",
"SQLException",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BigDecimal",
":",
"return",
"rs",
".",
"getBigDecimal",
"(",
"name",
")",
";",
"case",
"Boolean",
":",
"return",
"rs",
".",
"getBoolean",
"(",
"name",
")",
";",
"case",
"Byte",
":",
"return",
"rs",
".",
"getByte",
"(",
"name",
")",
";",
"case",
"Short",
":",
"return",
"rs",
".",
"getShort",
"(",
"name",
")",
";",
"case",
"Date",
":",
"return",
"rs",
".",
"getDate",
"(",
"name",
")",
";",
"case",
"Double",
":",
"return",
"rs",
".",
"getDouble",
"(",
"name",
")",
";",
"case",
"Float",
":",
"return",
"rs",
".",
"getFloat",
"(",
"name",
")",
";",
"case",
"Int",
":",
"return",
"rs",
".",
"getInt",
"(",
"name",
")",
";",
"case",
"Long",
":",
"return",
"rs",
".",
"getLong",
"(",
"name",
")",
";",
"case",
"Time",
":",
"return",
"rs",
".",
"getTime",
"(",
"name",
")",
";",
"case",
"Timestamp",
":",
"return",
"rs",
".",
"getTimestamp",
"(",
"name",
")",
";",
"default",
":",
"return",
"rs",
".",
"getString",
"(",
"name",
")",
";",
"}",
"}"
] |
Returns value of specified |column| according its type.
|
[
"Returns",
"value",
"of",
"specified",
"|column|",
"according",
"its",
"type",
"."
] |
a383dff20fadc08ec9306f2f1f24b2a7e0047449
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/studio/src/main/java/acolyte/JDBC.java#L92-L110
|
7,766 |
mygreen/xlsmapper
|
src/main/java/com/gh/mygreen/xlsmapper/xml/MultipleLoaderClassResolver.java
|
MultipleLoaderClassResolver.classForName
|
@SuppressWarnings({"unchecked", "rawtypes"})
public Class classForName(String className, Map loaderMap)
throws ClassNotFoundException {
Collection<ClassLoader> loaders = null;
// add context-classloader
loaders = new HashSet<ClassLoader>();
loaders.add(Thread.currentThread().getContextClassLoader());
if (loaderMap != null && !loaderMap.isEmpty()) {
loaders.addAll(loaderMap.values());
}
Class clazz = null;
ClassNotFoundException lastCause = null;
for (Iterator<ClassLoader> it = loaders.iterator(); it.hasNext();) {
ClassLoader loader = it.next();
try {
clazz = loader.loadClass(className);
return clazz;
} catch (ClassNotFoundException fqcnException) {
lastCause = fqcnException;
try {
if (className.indexOf('.') == -1) {
clazz = loader.loadClass("java.lang." + className);
return clazz;
}
} catch (ClassNotFoundException defaultClassException) {
lastCause = defaultClassException;
// try next loader.
}
}
}
// can't load class at end.
throw lastCause;
}
|
java
|
@SuppressWarnings({"unchecked", "rawtypes"})
public Class classForName(String className, Map loaderMap)
throws ClassNotFoundException {
Collection<ClassLoader> loaders = null;
// add context-classloader
loaders = new HashSet<ClassLoader>();
loaders.add(Thread.currentThread().getContextClassLoader());
if (loaderMap != null && !loaderMap.isEmpty()) {
loaders.addAll(loaderMap.values());
}
Class clazz = null;
ClassNotFoundException lastCause = null;
for (Iterator<ClassLoader> it = loaders.iterator(); it.hasNext();) {
ClassLoader loader = it.next();
try {
clazz = loader.loadClass(className);
return clazz;
} catch (ClassNotFoundException fqcnException) {
lastCause = fqcnException;
try {
if (className.indexOf('.') == -1) {
clazz = loader.loadClass("java.lang." + className);
return clazz;
}
} catch (ClassNotFoundException defaultClassException) {
lastCause = defaultClassException;
// try next loader.
}
}
}
// can't load class at end.
throw lastCause;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"Class",
"classForName",
"(",
"String",
"className",
",",
"Map",
"loaderMap",
")",
"throws",
"ClassNotFoundException",
"{",
"Collection",
"<",
"ClassLoader",
">",
"loaders",
"=",
"null",
";",
"// add context-classloader\r",
"loaders",
"=",
"new",
"HashSet",
"<",
"ClassLoader",
">",
"(",
")",
";",
"loaders",
".",
"add",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"if",
"(",
"loaderMap",
"!=",
"null",
"&&",
"!",
"loaderMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"loaders",
".",
"addAll",
"(",
"loaderMap",
".",
"values",
"(",
")",
")",
";",
"}",
"Class",
"clazz",
"=",
"null",
";",
"ClassNotFoundException",
"lastCause",
"=",
"null",
";",
"for",
"(",
"Iterator",
"<",
"ClassLoader",
">",
"it",
"=",
"loaders",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ClassLoader",
"loader",
"=",
"it",
".",
"next",
"(",
")",
";",
"try",
"{",
"clazz",
"=",
"loader",
".",
"loadClass",
"(",
"className",
")",
";",
"return",
"clazz",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"fqcnException",
")",
"{",
"lastCause",
"=",
"fqcnException",
";",
"try",
"{",
"if",
"(",
"className",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
"clazz",
"=",
"loader",
".",
"loadClass",
"(",
"\"java.lang.\"",
"+",
"className",
")",
";",
"return",
"clazz",
";",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"defaultClassException",
")",
"{",
"lastCause",
"=",
"defaultClassException",
";",
"// try next loader.\r",
"}",
"}",
"}",
"// can't load class at end.\r",
"throw",
"lastCause",
";",
"}"
] |
Loads class from multiple ClassLoader.
If this method can not load target class,
it tries to add package java.lang(default package)
and load target class.
Still, if it can not the class, throws ClassNotFoundException.
(behavior is put together on DefaultClassResolver.)
@param className class name -- that wants to load it.
@param loaderMap map -- that has VALUES ClassLoader (KEYS are arbitary).
@return loaded class from ClassLoader defined loaderMap.
|
[
"Loads",
"class",
"from",
"multiple",
"ClassLoader",
"."
] |
a0c6b25c622e5f3a50b199ef685d2ee46ad5483c
|
https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/xml/MultipleLoaderClassResolver.java#L30-L62
|
7,767 |
sonatype/sisu-guice
|
core/src/com/google/inject/internal/InternalInjectorCreator.java
|
InternalInjectorCreator.initializeStatically
|
private void initializeStatically() {
bindingData.initializeBindings();
stopwatch.resetAndLog("Binding initialization");
for (InjectorShell shell : shells) {
shell.getInjector().index();
}
stopwatch.resetAndLog("Binding indexing");
injectionRequestProcessor.process(shells);
stopwatch.resetAndLog("Collecting injection requests");
bindingData.runCreationListeners(errors);
stopwatch.resetAndLog("Binding validation");
injectionRequestProcessor.validate();
stopwatch.resetAndLog("Static validation");
initializer.validateOustandingInjections(errors);
stopwatch.resetAndLog("Instance member validation");
new LookupProcessor(errors).process(shells);
for (InjectorShell shell : shells) {
((DeferredLookups) shell.getInjector().lookups).initialize(errors);
}
stopwatch.resetAndLog("Provider verification");
// This needs to come late since some user bindings rely on requireBinding calls to create
// jit bindings during the LookupProcessor.
bindingData.initializeDelayedBindings();
stopwatch.resetAndLog("Delayed Binding initialization");
for (InjectorShell shell : shells) {
if (!shell.getElements().isEmpty()) {
throw new AssertionError("Failed to execute " + shell.getElements());
}
}
errors.throwCreationExceptionIfErrorsExist();
}
|
java
|
private void initializeStatically() {
bindingData.initializeBindings();
stopwatch.resetAndLog("Binding initialization");
for (InjectorShell shell : shells) {
shell.getInjector().index();
}
stopwatch.resetAndLog("Binding indexing");
injectionRequestProcessor.process(shells);
stopwatch.resetAndLog("Collecting injection requests");
bindingData.runCreationListeners(errors);
stopwatch.resetAndLog("Binding validation");
injectionRequestProcessor.validate();
stopwatch.resetAndLog("Static validation");
initializer.validateOustandingInjections(errors);
stopwatch.resetAndLog("Instance member validation");
new LookupProcessor(errors).process(shells);
for (InjectorShell shell : shells) {
((DeferredLookups) shell.getInjector().lookups).initialize(errors);
}
stopwatch.resetAndLog("Provider verification");
// This needs to come late since some user bindings rely on requireBinding calls to create
// jit bindings during the LookupProcessor.
bindingData.initializeDelayedBindings();
stopwatch.resetAndLog("Delayed Binding initialization");
for (InjectorShell shell : shells) {
if (!shell.getElements().isEmpty()) {
throw new AssertionError("Failed to execute " + shell.getElements());
}
}
errors.throwCreationExceptionIfErrorsExist();
}
|
[
"private",
"void",
"initializeStatically",
"(",
")",
"{",
"bindingData",
".",
"initializeBindings",
"(",
")",
";",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Binding initialization\"",
")",
";",
"for",
"(",
"InjectorShell",
"shell",
":",
"shells",
")",
"{",
"shell",
".",
"getInjector",
"(",
")",
".",
"index",
"(",
")",
";",
"}",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Binding indexing\"",
")",
";",
"injectionRequestProcessor",
".",
"process",
"(",
"shells",
")",
";",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Collecting injection requests\"",
")",
";",
"bindingData",
".",
"runCreationListeners",
"(",
"errors",
")",
";",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Binding validation\"",
")",
";",
"injectionRequestProcessor",
".",
"validate",
"(",
")",
";",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Static validation\"",
")",
";",
"initializer",
".",
"validateOustandingInjections",
"(",
"errors",
")",
";",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Instance member validation\"",
")",
";",
"new",
"LookupProcessor",
"(",
"errors",
")",
".",
"process",
"(",
"shells",
")",
";",
"for",
"(",
"InjectorShell",
"shell",
":",
"shells",
")",
"{",
"(",
"(",
"DeferredLookups",
")",
"shell",
".",
"getInjector",
"(",
")",
".",
"lookups",
")",
".",
"initialize",
"(",
"errors",
")",
";",
"}",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Provider verification\"",
")",
";",
"// This needs to come late since some user bindings rely on requireBinding calls to create",
"// jit bindings during the LookupProcessor.",
"bindingData",
".",
"initializeDelayedBindings",
"(",
")",
";",
"stopwatch",
".",
"resetAndLog",
"(",
"\"Delayed Binding initialization\"",
")",
";",
"for",
"(",
"InjectorShell",
"shell",
":",
"shells",
")",
"{",
"if",
"(",
"!",
"shell",
".",
"getElements",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"Failed to execute \"",
"+",
"shell",
".",
"getElements",
"(",
")",
")",
";",
"}",
"}",
"errors",
".",
"throwCreationExceptionIfErrorsExist",
"(",
")",
";",
"}"
] |
Initialize and validate everything.
|
[
"Initialize",
"and",
"validate",
"everything",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/internal/InternalInjectorCreator.java#L122-L161
|
7,768 |
sonatype/sisu-guice
|
core/src/com/google/inject/internal/InternalInjectorCreator.java
|
InternalInjectorCreator.loadEagerSingletons
|
void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors) {
List<BindingImpl<?>> candidateBindings = new ArrayList<>();
@SuppressWarnings("unchecked") // casting Collection<Binding> to Collection<BindingImpl> is safe
Collection<BindingImpl<?>> bindingsAtThisLevel =
(Collection) injector.state.getExplicitBindingsThisLevel().values();
candidateBindings.addAll(bindingsAtThisLevel);
synchronized (injector.state.lock()) {
// jit bindings must be accessed while holding the lock.
candidateBindings.addAll(injector.jitBindings.values());
}
InternalContext context = injector.enterContext();
try {
for (BindingImpl<?> binding : candidateBindings) {
if (isEagerSingleton(injector, binding, stage)) {
Dependency<?> dependency = Dependency.get(binding.getKey());
Dependency previous = context.pushDependency(dependency, binding.getSource());
try {
binding.getInternalFactory().get(context, dependency, false);
} catch (InternalProvisionException e) {
errors.withSource(dependency).merge(e);
} finally {
context.popStateAndSetDependency(previous);
}
}
}
} finally {
context.close();
}
}
|
java
|
void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors) {
List<BindingImpl<?>> candidateBindings = new ArrayList<>();
@SuppressWarnings("unchecked") // casting Collection<Binding> to Collection<BindingImpl> is safe
Collection<BindingImpl<?>> bindingsAtThisLevel =
(Collection) injector.state.getExplicitBindingsThisLevel().values();
candidateBindings.addAll(bindingsAtThisLevel);
synchronized (injector.state.lock()) {
// jit bindings must be accessed while holding the lock.
candidateBindings.addAll(injector.jitBindings.values());
}
InternalContext context = injector.enterContext();
try {
for (BindingImpl<?> binding : candidateBindings) {
if (isEagerSingleton(injector, binding, stage)) {
Dependency<?> dependency = Dependency.get(binding.getKey());
Dependency previous = context.pushDependency(dependency, binding.getSource());
try {
binding.getInternalFactory().get(context, dependency, false);
} catch (InternalProvisionException e) {
errors.withSource(dependency).merge(e);
} finally {
context.popStateAndSetDependency(previous);
}
}
}
} finally {
context.close();
}
}
|
[
"void",
"loadEagerSingletons",
"(",
"InjectorImpl",
"injector",
",",
"Stage",
"stage",
",",
"final",
"Errors",
"errors",
")",
"{",
"List",
"<",
"BindingImpl",
"<",
"?",
">",
">",
"candidateBindings",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// casting Collection<Binding> to Collection<BindingImpl> is safe",
"Collection",
"<",
"BindingImpl",
"<",
"?",
">",
">",
"bindingsAtThisLevel",
"=",
"(",
"Collection",
")",
"injector",
".",
"state",
".",
"getExplicitBindingsThisLevel",
"(",
")",
".",
"values",
"(",
")",
";",
"candidateBindings",
".",
"addAll",
"(",
"bindingsAtThisLevel",
")",
";",
"synchronized",
"(",
"injector",
".",
"state",
".",
"lock",
"(",
")",
")",
"{",
"// jit bindings must be accessed while holding the lock.",
"candidateBindings",
".",
"addAll",
"(",
"injector",
".",
"jitBindings",
".",
"values",
"(",
")",
")",
";",
"}",
"InternalContext",
"context",
"=",
"injector",
".",
"enterContext",
"(",
")",
";",
"try",
"{",
"for",
"(",
"BindingImpl",
"<",
"?",
">",
"binding",
":",
"candidateBindings",
")",
"{",
"if",
"(",
"isEagerSingleton",
"(",
"injector",
",",
"binding",
",",
"stage",
")",
")",
"{",
"Dependency",
"<",
"?",
">",
"dependency",
"=",
"Dependency",
".",
"get",
"(",
"binding",
".",
"getKey",
"(",
")",
")",
";",
"Dependency",
"previous",
"=",
"context",
".",
"pushDependency",
"(",
"dependency",
",",
"binding",
".",
"getSource",
"(",
")",
")",
";",
"try",
"{",
"binding",
".",
"getInternalFactory",
"(",
")",
".",
"get",
"(",
"context",
",",
"dependency",
",",
"false",
")",
";",
"}",
"catch",
"(",
"InternalProvisionException",
"e",
")",
"{",
"errors",
".",
"withSource",
"(",
"dependency",
")",
".",
"merge",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"context",
".",
"popStateAndSetDependency",
"(",
"previous",
")",
";",
"}",
"}",
"}",
"}",
"finally",
"{",
"context",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Loads eager singletons, or all singletons if we're in Stage.PRODUCTION. Bindings discovered
while we're binding these singletons are not be eager.
|
[
"Loads",
"eager",
"singletons",
"or",
"all",
"singletons",
"if",
"we",
"re",
"in",
"Stage",
".",
"PRODUCTION",
".",
"Bindings",
"discovered",
"while",
"we",
"re",
"binding",
"these",
"singletons",
"are",
"not",
"be",
"eager",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/internal/InternalInjectorCreator.java#L194-L223
|
7,769 |
sonatype/sisu-guice
|
extensions/throwingproviders/src/com/google/inject/throwingproviders/CheckedProvideUtils.java
|
CheckedProvideUtils.validateExceptions
|
static void validateExceptions(
Binder binder,
Iterable<TypeLiteral<?>> actualExceptionTypes,
Iterable<Class<? extends Throwable>> expectedExceptionTypes,
Class<? extends CheckedProvider> checkedProvider) {
// Validate the exceptions in the method match the exceptions
// in the CheckedProvider.
for (TypeLiteral<?> exType : actualExceptionTypes) {
Class<?> exActual = exType.getRawType();
// Ignore runtime exceptions & errors.
if (RuntimeException.class.isAssignableFrom(exActual)
|| Error.class.isAssignableFrom(exActual)) {
continue;
}
boolean notAssignable = true;
for (Class<? extends Throwable> exExpected : expectedExceptionTypes) {
if (exExpected.isAssignableFrom(exActual)) {
notAssignable = false;
break;
}
}
if (notAssignable) {
binder.addError(
"%s is not compatible with the exceptions (%s) declared in "
+ "the CheckedProvider interface (%s)",
exActual, expectedExceptionTypes, checkedProvider);
}
}
}
|
java
|
static void validateExceptions(
Binder binder,
Iterable<TypeLiteral<?>> actualExceptionTypes,
Iterable<Class<? extends Throwable>> expectedExceptionTypes,
Class<? extends CheckedProvider> checkedProvider) {
// Validate the exceptions in the method match the exceptions
// in the CheckedProvider.
for (TypeLiteral<?> exType : actualExceptionTypes) {
Class<?> exActual = exType.getRawType();
// Ignore runtime exceptions & errors.
if (RuntimeException.class.isAssignableFrom(exActual)
|| Error.class.isAssignableFrom(exActual)) {
continue;
}
boolean notAssignable = true;
for (Class<? extends Throwable> exExpected : expectedExceptionTypes) {
if (exExpected.isAssignableFrom(exActual)) {
notAssignable = false;
break;
}
}
if (notAssignable) {
binder.addError(
"%s is not compatible with the exceptions (%s) declared in "
+ "the CheckedProvider interface (%s)",
exActual, expectedExceptionTypes, checkedProvider);
}
}
}
|
[
"static",
"void",
"validateExceptions",
"(",
"Binder",
"binder",
",",
"Iterable",
"<",
"TypeLiteral",
"<",
"?",
">",
">",
"actualExceptionTypes",
",",
"Iterable",
"<",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
">",
"expectedExceptionTypes",
",",
"Class",
"<",
"?",
"extends",
"CheckedProvider",
">",
"checkedProvider",
")",
"{",
"// Validate the exceptions in the method match the exceptions",
"// in the CheckedProvider.",
"for",
"(",
"TypeLiteral",
"<",
"?",
">",
"exType",
":",
"actualExceptionTypes",
")",
"{",
"Class",
"<",
"?",
">",
"exActual",
"=",
"exType",
".",
"getRawType",
"(",
")",
";",
"// Ignore runtime exceptions & errors.",
"if",
"(",
"RuntimeException",
".",
"class",
".",
"isAssignableFrom",
"(",
"exActual",
")",
"||",
"Error",
".",
"class",
".",
"isAssignableFrom",
"(",
"exActual",
")",
")",
"{",
"continue",
";",
"}",
"boolean",
"notAssignable",
"=",
"true",
";",
"for",
"(",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"exExpected",
":",
"expectedExceptionTypes",
")",
"{",
"if",
"(",
"exExpected",
".",
"isAssignableFrom",
"(",
"exActual",
")",
")",
"{",
"notAssignable",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"notAssignable",
")",
"{",
"binder",
".",
"addError",
"(",
"\"%s is not compatible with the exceptions (%s) declared in \"",
"+",
"\"the CheckedProvider interface (%s)\"",
",",
"exActual",
",",
"expectedExceptionTypes",
",",
"checkedProvider",
")",
";",
"}",
"}",
"}"
] |
Adds errors to the binder if the exceptions aren't valid.
|
[
"Adds",
"errors",
"to",
"the",
"binder",
"if",
"the",
"exceptions",
"aren",
"t",
"valid",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/extensions/throwingproviders/src/com/google/inject/throwingproviders/CheckedProvideUtils.java#L78-L107
|
7,770 |
sonatype/sisu-guice
|
core/src/com/google/inject/internal/RealOptionalBinder.java
|
RealOptionalBinder.invokeJavaOptionalOf
|
private static Object invokeJavaOptionalOf(Object o) {
try {
return JAVA_OPTIONAL_OF_METHOD.invoke(null, o);
} catch (IllegalAccessException e) {
throw new SecurityException(e);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(e);
} catch (InvocationTargetException e) {
throw Throwables.propagate(e.getCause());
}
}
|
java
|
private static Object invokeJavaOptionalOf(Object o) {
try {
return JAVA_OPTIONAL_OF_METHOD.invoke(null, o);
} catch (IllegalAccessException e) {
throw new SecurityException(e);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(e);
} catch (InvocationTargetException e) {
throw Throwables.propagate(e.getCause());
}
}
|
[
"private",
"static",
"Object",
"invokeJavaOptionalOf",
"(",
"Object",
"o",
")",
"{",
"try",
"{",
"return",
"JAVA_OPTIONAL_OF_METHOD",
".",
"invoke",
"(",
"null",
",",
"o",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"}"
] |
Invokes java.util.Optional.of.
|
[
"Invokes",
"java",
".",
"util",
".",
"Optional",
".",
"of",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/internal/RealOptionalBinder.java#L106-L116
|
7,771 |
sonatype/sisu-guice
|
extensions/servlet/src/com/google/inject/servlet/ServletDefinition.java
|
ServletDefinition.service
|
boolean service(ServletRequest servletRequest, ServletResponse servletResponse)
throws IOException, ServletException {
final HttpServletRequest request = (HttpServletRequest) servletRequest;
final String path = ServletUtils.getContextRelativePath(request);
final boolean serve = shouldServe(path);
//invocations of the chain end at the first matched servlet
if (serve) {
doService(servletRequest, servletResponse);
}
//return false if no servlet matched (so we can proceed down to the web.xml servlets)
return serve;
}
|
java
|
boolean service(ServletRequest servletRequest, ServletResponse servletResponse)
throws IOException, ServletException {
final HttpServletRequest request = (HttpServletRequest) servletRequest;
final String path = ServletUtils.getContextRelativePath(request);
final boolean serve = shouldServe(path);
//invocations of the chain end at the first matched servlet
if (serve) {
doService(servletRequest, servletResponse);
}
//return false if no servlet matched (so we can proceed down to the web.xml servlets)
return serve;
}
|
[
"boolean",
"service",
"(",
"ServletRequest",
"servletRequest",
",",
"ServletResponse",
"servletResponse",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"final",
"HttpServletRequest",
"request",
"=",
"(",
"HttpServletRequest",
")",
"servletRequest",
";",
"final",
"String",
"path",
"=",
"ServletUtils",
".",
"getContextRelativePath",
"(",
"request",
")",
";",
"final",
"boolean",
"serve",
"=",
"shouldServe",
"(",
"path",
")",
";",
"//invocations of the chain end at the first matched servlet",
"if",
"(",
"serve",
")",
"{",
"doService",
"(",
"servletRequest",
",",
"servletResponse",
")",
";",
"}",
"//return false if no servlet matched (so we can proceed down to the web.xml servlets)",
"return",
"serve",
";",
"}"
] |
Wrapper around the service chain to ensure a servlet is servicing what it must and provides it
with a wrapped request.
@return Returns true if this servlet triggered for the given request. Or false if guice-servlet
should continue dispatching down the servlet pipeline.
@throws IOException If thrown by underlying servlet
@throws ServletException If thrown by underlying servlet
|
[
"Wrapper",
"around",
"the",
"service",
"chain",
"to",
"ensure",
"a",
"servlet",
"is",
"servicing",
"what",
"it",
"must",
"and",
"provides",
"it",
"with",
"a",
"wrapped",
"request",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/extensions/servlet/src/com/google/inject/servlet/ServletDefinition.java#L178-L193
|
7,772 |
sonatype/sisu-guice
|
core/src/com/google/inject/matcher/Matchers.java
|
Matchers.not
|
public static <T> Matcher<T> not(final Matcher<? super T> p) {
return new Not<T>(p);
}
|
java
|
public static <T> Matcher<T> not(final Matcher<? super T> p) {
return new Not<T>(p);
}
|
[
"public",
"static",
"<",
"T",
">",
"Matcher",
"<",
"T",
">",
"not",
"(",
"final",
"Matcher",
"<",
"?",
"super",
"T",
">",
"p",
")",
"{",
"return",
"new",
"Not",
"<",
"T",
">",
"(",
"p",
")",
";",
"}"
] |
Inverts the given matcher.
|
[
"Inverts",
"the",
"given",
"matcher",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/matcher/Matchers.java#L63-L65
|
7,773 |
damiencarol/jsr203-hadoop
|
src/main/java/hdfs/jsr203/HadoopFileSystemProvider.java
|
HadoopFileSystemProvider.toHadoopPath
|
private static final HadoopPath toHadoopPath(Path path) {
if (path == null) {
throw new NullPointerException();
}
if (!(path instanceof HadoopPath)) {
throw new ProviderMismatchException();
}
return (HadoopPath) path;
}
|
java
|
private static final HadoopPath toHadoopPath(Path path) {
if (path == null) {
throw new NullPointerException();
}
if (!(path instanceof HadoopPath)) {
throw new ProviderMismatchException();
}
return (HadoopPath) path;
}
|
[
"private",
"static",
"final",
"HadoopPath",
"toHadoopPath",
"(",
"Path",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"(",
"path",
"instanceof",
"HadoopPath",
")",
")",
"{",
"throw",
"new",
"ProviderMismatchException",
"(",
")",
";",
"}",
"return",
"(",
"HadoopPath",
")",
"path",
";",
"}"
] |
Checks that the given file is a HadoopPath
|
[
"Checks",
"that",
"the",
"given",
"file",
"is",
"a",
"HadoopPath"
] |
d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057
|
https://github.com/damiencarol/jsr203-hadoop/blob/d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057/src/main/java/hdfs/jsr203/HadoopFileSystemProvider.java#L63-L71
|
7,774 |
sonatype/sisu-guice
|
core/src/com/google/inject/internal/InjectorShell.java
|
InjectorShell.bindLogger
|
private static void bindLogger(InjectorImpl injector) {
Key<Logger> key = Key.get(Logger.class);
LoggerFactory loggerFactory = new LoggerFactory();
injector.state.putBinding(
key,
new ProviderInstanceBindingImpl<Logger>(
injector,
key,
SourceProvider.UNKNOWN_SOURCE,
loggerFactory,
Scoping.UNSCOPED,
loggerFactory,
ImmutableSet.<InjectionPoint>of()));
try {
Key<org.slf4j.Logger> slf4jKey = Key.get(org.slf4j.Logger.class);
SLF4JLoggerFactory slf4jLoggerFactory = new SLF4JLoggerFactory(injector);
injector.state.putBinding(slf4jKey,
new ProviderInstanceBindingImpl<org.slf4j.Logger>(injector, slf4jKey,
SourceProvider.UNKNOWN_SOURCE, slf4jLoggerFactory, Scoping.UNSCOPED,
slf4jLoggerFactory, ImmutableSet.<InjectionPoint>of()));
} catch (Throwable e) {}
}
|
java
|
private static void bindLogger(InjectorImpl injector) {
Key<Logger> key = Key.get(Logger.class);
LoggerFactory loggerFactory = new LoggerFactory();
injector.state.putBinding(
key,
new ProviderInstanceBindingImpl<Logger>(
injector,
key,
SourceProvider.UNKNOWN_SOURCE,
loggerFactory,
Scoping.UNSCOPED,
loggerFactory,
ImmutableSet.<InjectionPoint>of()));
try {
Key<org.slf4j.Logger> slf4jKey = Key.get(org.slf4j.Logger.class);
SLF4JLoggerFactory slf4jLoggerFactory = new SLF4JLoggerFactory(injector);
injector.state.putBinding(slf4jKey,
new ProviderInstanceBindingImpl<org.slf4j.Logger>(injector, slf4jKey,
SourceProvider.UNKNOWN_SOURCE, slf4jLoggerFactory, Scoping.UNSCOPED,
slf4jLoggerFactory, ImmutableSet.<InjectionPoint>of()));
} catch (Throwable e) {}
}
|
[
"private",
"static",
"void",
"bindLogger",
"(",
"InjectorImpl",
"injector",
")",
"{",
"Key",
"<",
"Logger",
">",
"key",
"=",
"Key",
".",
"get",
"(",
"Logger",
".",
"class",
")",
";",
"LoggerFactory",
"loggerFactory",
"=",
"new",
"LoggerFactory",
"(",
")",
";",
"injector",
".",
"state",
".",
"putBinding",
"(",
"key",
",",
"new",
"ProviderInstanceBindingImpl",
"<",
"Logger",
">",
"(",
"injector",
",",
"key",
",",
"SourceProvider",
".",
"UNKNOWN_SOURCE",
",",
"loggerFactory",
",",
"Scoping",
".",
"UNSCOPED",
",",
"loggerFactory",
",",
"ImmutableSet",
".",
"<",
"InjectionPoint",
">",
"of",
"(",
")",
")",
")",
";",
"try",
"{",
"Key",
"<",
"org",
".",
"slf4j",
".",
"Logger",
">",
"slf4jKey",
"=",
"Key",
".",
"get",
"(",
"org",
".",
"slf4j",
".",
"Logger",
".",
"class",
")",
";",
"SLF4JLoggerFactory",
"slf4jLoggerFactory",
"=",
"new",
"SLF4JLoggerFactory",
"(",
"injector",
")",
";",
"injector",
".",
"state",
".",
"putBinding",
"(",
"slf4jKey",
",",
"new",
"ProviderInstanceBindingImpl",
"<",
"org",
".",
"slf4j",
".",
"Logger",
">",
"(",
"injector",
",",
"slf4jKey",
",",
"SourceProvider",
".",
"UNKNOWN_SOURCE",
",",
"slf4jLoggerFactory",
",",
"Scoping",
".",
"UNSCOPED",
",",
"slf4jLoggerFactory",
",",
"ImmutableSet",
".",
"<",
"InjectionPoint",
">",
"of",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"}",
"}"
] |
The Logger is a special case because it knows the injection point of the injected member. It's
the only binding that does this.
|
[
"The",
"Logger",
"is",
"a",
"special",
"case",
"because",
"it",
"knows",
"the",
"injection",
"point",
"of",
"the",
"injected",
"member",
".",
"It",
"s",
"the",
"only",
"binding",
"that",
"does",
"this",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/internal/InjectorShell.java#L260-L282
|
7,775 |
sonatype/sisu-guice
|
core/src/com/google/inject/ConfigurationException.java
|
ConfigurationException.withPartialValue
|
public ConfigurationException withPartialValue(Object partialValue) {
checkState(this.partialValue == null,
"Can't clobber existing partial value %s with %s", this.partialValue, partialValue);
ConfigurationException result = new ConfigurationException(messages);
result.partialValue = partialValue;
return result;
}
|
java
|
public ConfigurationException withPartialValue(Object partialValue) {
checkState(this.partialValue == null,
"Can't clobber existing partial value %s with %s", this.partialValue, partialValue);
ConfigurationException result = new ConfigurationException(messages);
result.partialValue = partialValue;
return result;
}
|
[
"public",
"ConfigurationException",
"withPartialValue",
"(",
"Object",
"partialValue",
")",
"{",
"checkState",
"(",
"this",
".",
"partialValue",
"==",
"null",
",",
"\"Can't clobber existing partial value %s with %s\"",
",",
"this",
".",
"partialValue",
",",
"partialValue",
")",
";",
"ConfigurationException",
"result",
"=",
"new",
"ConfigurationException",
"(",
"messages",
")",
";",
"result",
".",
"partialValue",
"=",
"partialValue",
";",
"return",
"result",
";",
"}"
] |
Returns a copy of this configuration exception with the specified partial value.
|
[
"Returns",
"a",
"copy",
"of",
"this",
"configuration",
"exception",
"with",
"the",
"specified",
"partial",
"value",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/ConfigurationException.java#L44-L50
|
7,776 |
sonatype/sisu-guice
|
core/src/com/google/inject/spi/Dependency.java
|
Dependency.get
|
public static <T> Dependency<T> get(Key<T> key) {
return new Dependency<T>(null, MoreTypes.canonicalizeKey(key), true, -1);
}
|
java
|
public static <T> Dependency<T> get(Key<T> key) {
return new Dependency<T>(null, MoreTypes.canonicalizeKey(key), true, -1);
}
|
[
"public",
"static",
"<",
"T",
">",
"Dependency",
"<",
"T",
">",
"get",
"(",
"Key",
"<",
"T",
">",
"key",
")",
"{",
"return",
"new",
"Dependency",
"<",
"T",
">",
"(",
"null",
",",
"MoreTypes",
".",
"canonicalizeKey",
"(",
"key",
")",
",",
"true",
",",
"-",
"1",
")",
";",
"}"
] |
Returns a new dependency that is not attached to an injection point. The returned dependency is
nullable.
|
[
"Returns",
"a",
"new",
"dependency",
"that",
"is",
"not",
"attached",
"to",
"an",
"injection",
"point",
".",
"The",
"returned",
"dependency",
"is",
"nullable",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/spi/Dependency.java#L56-L58
|
7,777 |
sonatype/sisu-guice
|
core/src/com/google/inject/spi/Dependency.java
|
Dependency.forInjectionPoints
|
public static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints) {
List<Dependency<?>> dependencies = Lists.newArrayList();
for (InjectionPoint injectionPoint : injectionPoints) {
dependencies.addAll(injectionPoint.getDependencies());
}
return ImmutableSet.copyOf(dependencies);
}
|
java
|
public static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints) {
List<Dependency<?>> dependencies = Lists.newArrayList();
for (InjectionPoint injectionPoint : injectionPoints) {
dependencies.addAll(injectionPoint.getDependencies());
}
return ImmutableSet.copyOf(dependencies);
}
|
[
"public",
"static",
"Set",
"<",
"Dependency",
"<",
"?",
">",
">",
"forInjectionPoints",
"(",
"Set",
"<",
"InjectionPoint",
">",
"injectionPoints",
")",
"{",
"List",
"<",
"Dependency",
"<",
"?",
">",
">",
"dependencies",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"InjectionPoint",
"injectionPoint",
":",
"injectionPoints",
")",
"{",
"dependencies",
".",
"addAll",
"(",
"injectionPoint",
".",
"getDependencies",
"(",
")",
")",
";",
"}",
"return",
"ImmutableSet",
".",
"copyOf",
"(",
"dependencies",
")",
";",
"}"
] |
Returns the dependencies from the given injection points.
|
[
"Returns",
"the",
"dependencies",
"from",
"the",
"given",
"injection",
"points",
"."
] |
45f5c89834c189c5338640bf55e6e6181b9b5611
|
https://github.com/sonatype/sisu-guice/blob/45f5c89834c189c5338640bf55e6e6181b9b5611/core/src/com/google/inject/spi/Dependency.java#L61-L67
|
7,778 |
damiencarol/jsr203-hadoop
|
src/main/java/hdfs/jsr203/HadoopPath.java
|
HadoopPath.normalize
|
private byte[] normalize(byte[] path) {
if (path.length == 0)
return path;
byte prevC = 0;
for (int i = 0; i < path.length; i++) {
byte c = path[i];
if (c == '\\')
return normalize(path, i);
if (c == (byte) '/' && prevC == '/')
return normalize(path, i - 1);
if (c == '\u0000')
throw new InvalidPathException(this.hdfs.getString(path),
"Path: nul character not allowed");
prevC = c;
}
return path;
}
|
java
|
private byte[] normalize(byte[] path) {
if (path.length == 0)
return path;
byte prevC = 0;
for (int i = 0; i < path.length; i++) {
byte c = path[i];
if (c == '\\')
return normalize(path, i);
if (c == (byte) '/' && prevC == '/')
return normalize(path, i - 1);
if (c == '\u0000')
throw new InvalidPathException(this.hdfs.getString(path),
"Path: nul character not allowed");
prevC = c;
}
return path;
}
|
[
"private",
"byte",
"[",
"]",
"normalize",
"(",
"byte",
"[",
"]",
"path",
")",
"{",
"if",
"(",
"path",
".",
"length",
"==",
"0",
")",
"return",
"path",
";",
"byte",
"prevC",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"path",
".",
"length",
";",
"i",
"++",
")",
"{",
"byte",
"c",
"=",
"path",
"[",
"i",
"]",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"return",
"normalize",
"(",
"path",
",",
"i",
")",
";",
"if",
"(",
"c",
"==",
"(",
"byte",
")",
"'",
"'",
"&&",
"prevC",
"==",
"'",
"'",
")",
"return",
"normalize",
"(",
"path",
",",
"i",
"-",
"1",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"throw",
"new",
"InvalidPathException",
"(",
"this",
".",
"hdfs",
".",
"getString",
"(",
"path",
")",
",",
"\"Path: nul character not allowed\"",
")",
";",
"prevC",
"=",
"c",
";",
"}",
"return",
"path",
";",
"}"
] |
and check for invalid characters
|
[
"and",
"check",
"for",
"invalid",
"characters"
] |
d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057
|
https://github.com/damiencarol/jsr203-hadoop/blob/d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057/src/main/java/hdfs/jsr203/HadoopPath.java#L264-L280
|
7,779 |
damiencarol/jsr203-hadoop
|
src/main/java/hdfs/jsr203/HadoopPath.java
|
HadoopPath.getRawResolvedPath
|
public org.apache.hadoop.fs.Path getRawResolvedPath() {
return new org.apache.hadoop.fs.Path("hdfs://" + hdfs.getHost() + ":"
+ hdfs.getPort() + new String(getResolvedPath()));
}
|
java
|
public org.apache.hadoop.fs.Path getRawResolvedPath() {
return new org.apache.hadoop.fs.Path("hdfs://" + hdfs.getHost() + ":"
+ hdfs.getPort() + new String(getResolvedPath()));
}
|
[
"public",
"org",
".",
"apache",
".",
"hadoop",
".",
"fs",
".",
"Path",
"getRawResolvedPath",
"(",
")",
"{",
"return",
"new",
"org",
".",
"apache",
".",
"hadoop",
".",
"fs",
".",
"Path",
"(",
"\"hdfs://\"",
"+",
"hdfs",
".",
"getHost",
"(",
")",
"+",
"\":\"",
"+",
"hdfs",
".",
"getPort",
"(",
")",
"+",
"new",
"String",
"(",
"getResolvedPath",
"(",
")",
")",
")",
";",
"}"
] |
Helper to get the raw interface of HDFS path.
@return raw HDFS path object
|
[
"Helper",
"to",
"get",
"the",
"raw",
"interface",
"of",
"HDFS",
"path",
"."
] |
d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057
|
https://github.com/damiencarol/jsr203-hadoop/blob/d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057/src/main/java/hdfs/jsr203/HadoopPath.java#L534-L537
|
7,780 |
damiencarol/jsr203-hadoop
|
src/main/java/hdfs/jsr203/HadoopPath.java
|
HadoopPath.initOffsets
|
private void initOffsets() {
if (offsets == null) {
int count;
int index;
// count names
count = 0;
index = 0;
while (index < path.length) {
byte c = path[index++];
if (c != '/') {
count++;
while (index < path.length && path[index] != '/')
index++;
}
}
// populate offsets
int[] result = new int[count];
count = 0;
index = 0;
while (index < path.length) {
byte c = path[index];
if (c == '/') {
index++;
} else {
result[count++] = index++;
while (index < path.length && path[index] != '/')
index++;
}
}
synchronized (this) {
if (offsets == null)
offsets = result;
}
}
}
|
java
|
private void initOffsets() {
if (offsets == null) {
int count;
int index;
// count names
count = 0;
index = 0;
while (index < path.length) {
byte c = path[index++];
if (c != '/') {
count++;
while (index < path.length && path[index] != '/')
index++;
}
}
// populate offsets
int[] result = new int[count];
count = 0;
index = 0;
while (index < path.length) {
byte c = path[index];
if (c == '/') {
index++;
} else {
result[count++] = index++;
while (index < path.length && path[index] != '/')
index++;
}
}
synchronized (this) {
if (offsets == null)
offsets = result;
}
}
}
|
[
"private",
"void",
"initOffsets",
"(",
")",
"{",
"if",
"(",
"offsets",
"==",
"null",
")",
"{",
"int",
"count",
";",
"int",
"index",
";",
"// count names",
"count",
"=",
"0",
";",
"index",
"=",
"0",
";",
"while",
"(",
"index",
"<",
"path",
".",
"length",
")",
"{",
"byte",
"c",
"=",
"path",
"[",
"index",
"++",
"]",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
")",
"{",
"count",
"++",
";",
"while",
"(",
"index",
"<",
"path",
".",
"length",
"&&",
"path",
"[",
"index",
"]",
"!=",
"'",
"'",
")",
"index",
"++",
";",
"}",
"}",
"// populate offsets",
"int",
"[",
"]",
"result",
"=",
"new",
"int",
"[",
"count",
"]",
";",
"count",
"=",
"0",
";",
"index",
"=",
"0",
";",
"while",
"(",
"index",
"<",
"path",
".",
"length",
")",
"{",
"byte",
"c",
"=",
"path",
"[",
"index",
"]",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"index",
"++",
";",
"}",
"else",
"{",
"result",
"[",
"count",
"++",
"]",
"=",
"index",
"++",
";",
"while",
"(",
"index",
"<",
"path",
".",
"length",
"&&",
"path",
"[",
"index",
"]",
"!=",
"'",
"'",
")",
"index",
"++",
";",
"}",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"offsets",
"==",
"null",
")",
"offsets",
"=",
"result",
";",
"}",
"}",
"}"
] |
create offset list if not already created
|
[
"create",
"offset",
"list",
"if",
"not",
"already",
"created"
] |
d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057
|
https://github.com/damiencarol/jsr203-hadoop/blob/d36a4b0c6498fc5d25ce79bd8c5bb69c6ef70057/src/main/java/hdfs/jsr203/HadoopPath.java#L661-L695
|
7,781 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
|
IndexedStorage.storageDelegate
|
public Storage<S> storageDelegate(StorableIndex<S> index) {
if (mAllIndexInfoMap.get(index) instanceof ManagedIndex) {
// Index is managed by this storage, which is typical.
return null;
}
// Index is managed by master storage, most likely a primary key index.
return mMasterStorage;
}
|
java
|
public Storage<S> storageDelegate(StorableIndex<S> index) {
if (mAllIndexInfoMap.get(index) instanceof ManagedIndex) {
// Index is managed by this storage, which is typical.
return null;
}
// Index is managed by master storage, most likely a primary key index.
return mMasterStorage;
}
|
[
"public",
"Storage",
"<",
"S",
">",
"storageDelegate",
"(",
"StorableIndex",
"<",
"S",
">",
"index",
")",
"{",
"if",
"(",
"mAllIndexInfoMap",
".",
"get",
"(",
"index",
")",
"instanceof",
"ManagedIndex",
")",
"{",
"// Index is managed by this storage, which is typical.\r",
"return",
"null",
";",
"}",
"// Index is managed by master storage, most likely a primary key index.\r",
"return",
"mMasterStorage",
";",
"}"
] |
Required by StorageAccess.
|
[
"Required",
"by",
"StorageAccess",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java#L197-L204
|
7,782 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/util/AnnotationDescPrinter.java
|
AnnotationDescPrinter.makePlainDescriptor
|
public static String makePlainDescriptor(Class<? extends Annotation> annotationType) {
return "" + TAG_ANNOTATION + TypeDesc.forClass(annotationType).getDescriptor();
}
|
java
|
public static String makePlainDescriptor(Class<? extends Annotation> annotationType) {
return "" + TAG_ANNOTATION + TypeDesc.forClass(annotationType).getDescriptor();
}
|
[
"public",
"static",
"String",
"makePlainDescriptor",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationType",
")",
"{",
"return",
"\"\"",
"+",
"TAG_ANNOTATION",
"+",
"TypeDesc",
".",
"forClass",
"(",
"annotationType",
")",
".",
"getDescriptor",
"(",
")",
";",
"}"
] |
Returns an annotation descriptor that has no parameters.
|
[
"Returns",
"an",
"annotation",
"descriptor",
"that",
"has",
"no",
"parameters",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/AnnotationDescPrinter.java#L35-L37
|
7,783 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/CorruptEncodingException.java
|
CorruptEncodingException.writeObject
|
private void writeObject(ObjectOutputStream out) throws IOException {
Storable s = mStorable;
if (s == null) {
out.write(0);
} else {
out.write(1);
out.writeObject(s.storableType());
try {
s.writeTo(out);
} catch (SupportException e) {
throw new IOException(e);
}
}
}
|
java
|
private void writeObject(ObjectOutputStream out) throws IOException {
Storable s = mStorable;
if (s == null) {
out.write(0);
} else {
out.write(1);
out.writeObject(s.storableType());
try {
s.writeTo(out);
} catch (SupportException e) {
throw new IOException(e);
}
}
}
|
[
"private",
"void",
"writeObject",
"(",
"ObjectOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"Storable",
"s",
"=",
"mStorable",
";",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"out",
".",
"write",
"(",
"0",
")",
";",
"}",
"else",
"{",
"out",
".",
"write",
"(",
"1",
")",
";",
"out",
".",
"writeObject",
"(",
"s",
".",
"storableType",
"(",
")",
")",
";",
"try",
"{",
"s",
".",
"writeTo",
"(",
"out",
")",
";",
"}",
"catch",
"(",
"SupportException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
server is identical. Linking into the actual repository is a bit trickier.
|
[
"server",
"is",
"identical",
".",
"Linking",
"into",
"the",
"actual",
"repository",
"is",
"a",
"bit",
"trickier",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/CorruptEncodingException.java#L101-L114
|
7,784 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GzipCompressor.java
|
GzipCompressor.compress
|
public static byte[] compress(byte[] value, int prefix) throws SupportException {
Deflater compressor = cLocalDeflater.get();
if (compressor == null) {
cLocalDeflater.set(compressor = new Deflater());
}
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
try {
bos.write(value, 0, prefix);
DeflaterOutputStream dout = new DeflaterOutputStream(bos, compressor);
dout.write(value, prefix, value.length - prefix);
dout.close();
return bos.toByteArray();
} catch (IOException e) {
throw new SupportException(e);
} finally {
compressor.reset();
}
}
|
java
|
public static byte[] compress(byte[] value, int prefix) throws SupportException {
Deflater compressor = cLocalDeflater.get();
if (compressor == null) {
cLocalDeflater.set(compressor = new Deflater());
}
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
try {
bos.write(value, 0, prefix);
DeflaterOutputStream dout = new DeflaterOutputStream(bos, compressor);
dout.write(value, prefix, value.length - prefix);
dout.close();
return bos.toByteArray();
} catch (IOException e) {
throw new SupportException(e);
} finally {
compressor.reset();
}
}
|
[
"public",
"static",
"byte",
"[",
"]",
"compress",
"(",
"byte",
"[",
"]",
"value",
",",
"int",
"prefix",
")",
"throws",
"SupportException",
"{",
"Deflater",
"compressor",
"=",
"cLocalDeflater",
".",
"get",
"(",
")",
";",
"if",
"(",
"compressor",
"==",
"null",
")",
"{",
"cLocalDeflater",
".",
"set",
"(",
"compressor",
"=",
"new",
"Deflater",
"(",
")",
")",
";",
"}",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
"value",
".",
"length",
")",
";",
"try",
"{",
"bos",
".",
"write",
"(",
"value",
",",
"0",
",",
"prefix",
")",
";",
"DeflaterOutputStream",
"dout",
"=",
"new",
"DeflaterOutputStream",
"(",
"bos",
",",
"compressor",
")",
";",
"dout",
".",
"write",
"(",
"value",
",",
"prefix",
",",
"value",
".",
"length",
"-",
"prefix",
")",
";",
"dout",
".",
"close",
"(",
")",
";",
"return",
"bos",
".",
"toByteArray",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SupportException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"compressor",
".",
"reset",
"(",
")",
";",
"}",
"}"
] |
Encodes into compressed form.
@param value value to compress
@param prefix prefix of byte array to preserve
@return compressed value
@throws SupportException thrown if compression failed
|
[
"Encodes",
"into",
"compressed",
"form",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GzipCompressor.java#L53-L72
|
7,785 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GzipCompressor.java
|
GzipCompressor.decompress
|
public static byte[] decompress(byte[] value, int prefix) throws CorruptEncodingException {
Inflater inflater = cLocalInflater.get();
if (inflater == null) {
cLocalInflater.set(inflater = new Inflater());
}
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length * 2);
try {
bos.write(value, 0, prefix);
InflaterOutputStream ios = new InflaterOutputStream(bos, inflater);
ios.write(value, prefix, value.length - prefix);
ios.close();
return bos.toByteArray();
} catch (ZipException e) {
// Assume it wasn't compressed.
return value;
} catch (IOException e) {
throw new CorruptEncodingException(e);
} finally {
inflater.reset();
}
}
|
java
|
public static byte[] decompress(byte[] value, int prefix) throws CorruptEncodingException {
Inflater inflater = cLocalInflater.get();
if (inflater == null) {
cLocalInflater.set(inflater = new Inflater());
}
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length * 2);
try {
bos.write(value, 0, prefix);
InflaterOutputStream ios = new InflaterOutputStream(bos, inflater);
ios.write(value, prefix, value.length - prefix);
ios.close();
return bos.toByteArray();
} catch (ZipException e) {
// Assume it wasn't compressed.
return value;
} catch (IOException e) {
throw new CorruptEncodingException(e);
} finally {
inflater.reset();
}
}
|
[
"public",
"static",
"byte",
"[",
"]",
"decompress",
"(",
"byte",
"[",
"]",
"value",
",",
"int",
"prefix",
")",
"throws",
"CorruptEncodingException",
"{",
"Inflater",
"inflater",
"=",
"cLocalInflater",
".",
"get",
"(",
")",
";",
"if",
"(",
"inflater",
"==",
"null",
")",
"{",
"cLocalInflater",
".",
"set",
"(",
"inflater",
"=",
"new",
"Inflater",
"(",
")",
")",
";",
"}",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
"value",
".",
"length",
"*",
"2",
")",
";",
"try",
"{",
"bos",
".",
"write",
"(",
"value",
",",
"0",
",",
"prefix",
")",
";",
"InflaterOutputStream",
"ios",
"=",
"new",
"InflaterOutputStream",
"(",
"bos",
",",
"inflater",
")",
";",
"ios",
".",
"write",
"(",
"value",
",",
"prefix",
",",
"value",
".",
"length",
"-",
"prefix",
")",
";",
"ios",
".",
"close",
"(",
")",
";",
"return",
"bos",
".",
"toByteArray",
"(",
")",
";",
"}",
"catch",
"(",
"ZipException",
"e",
")",
"{",
"// Assume it wasn't compressed.",
"return",
"value",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"CorruptEncodingException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"inflater",
".",
"reset",
"(",
")",
";",
"}",
"}"
] |
Decodes from compressed form.
@param value value to decompress
@param prefix prefix of byte array to preserve
@return decompressed value
@throws CorruptEncodingException thrown if value cannot be decompressed
|
[
"Decodes",
"from",
"compressed",
"form",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GzipCompressor.java#L82-L104
|
7,786 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java
|
ReplicatedRepository.selectNaturalOrder
|
private static <S extends Storable> String[] selectNaturalOrder(Repository repo,
Class<S> type,
Filter<S> filter)
throws RepositoryException
{
if (!filter.isOpen() && repo instanceof RepositoryAccess) {
UnionQueryAnalyzer.Result result =
new UnionQueryAnalyzer(type, (RepositoryAccess) repo)
.analyze(filter, null, QueryHints.emptyHints().with(QueryHint.CONSUME_SLICE));
OrderingList<S> ordering = result.getTotalOrdering();
if (ordering == null) {
List<IndexedQueryAnalyzer.Result> list = result.getSubResults();
if (!list.isEmpty()) {
StorableIndex<S> index = list.get(0).getLocalIndex();
if (index != null) {
ordering = OrderingList.get(index.getOrderedProperties());
}
}
}
if (ordering != null) {
String[] props = new String[ordering.size()];
for (int i=0; i<props.length; i++) {
props[i] = ordering.get(i).toString();
}
return props;
}
}
IndexInfoCapability capability = repo.getCapability(IndexInfoCapability.class);
if (capability == null) {
return null;
}
IndexInfo info = null;
for (IndexInfo candidate : capability.getIndexInfo(type)) {
if (candidate.isClustered()) {
info = candidate;
break;
}
}
if (info == null) {
return null;
}
// Verify index is part of primary key.
Set<String> pkSet = StorableIntrospector.examine(type).getPrimaryKeyProperties().keySet();
String[] propNames = info.getPropertyNames();
for (String prop : propNames) {
if (!pkSet.contains(prop)) {
return null;
}
}
String[] orderBy = new String[pkSet.size()];
Direction[] directions = info.getPropertyDirections();
// Clone to remove elements.
pkSet = new LinkedHashSet<String>(pkSet);
int i;
for (i=0; i<propNames.length; i++) {
orderBy[i] = ((directions[i] == Direction.DESCENDING) ? "-" : "+") + propNames[i];
pkSet.remove(propNames[i]);
}
// Append any remaining pk properties, to ensure complete ordering.
if (pkSet.size() > 0) {
for (String prop : pkSet) {
orderBy[i++] = prop;
}
}
return orderBy;
}
|
java
|
private static <S extends Storable> String[] selectNaturalOrder(Repository repo,
Class<S> type,
Filter<S> filter)
throws RepositoryException
{
if (!filter.isOpen() && repo instanceof RepositoryAccess) {
UnionQueryAnalyzer.Result result =
new UnionQueryAnalyzer(type, (RepositoryAccess) repo)
.analyze(filter, null, QueryHints.emptyHints().with(QueryHint.CONSUME_SLICE));
OrderingList<S> ordering = result.getTotalOrdering();
if (ordering == null) {
List<IndexedQueryAnalyzer.Result> list = result.getSubResults();
if (!list.isEmpty()) {
StorableIndex<S> index = list.get(0).getLocalIndex();
if (index != null) {
ordering = OrderingList.get(index.getOrderedProperties());
}
}
}
if (ordering != null) {
String[] props = new String[ordering.size()];
for (int i=0; i<props.length; i++) {
props[i] = ordering.get(i).toString();
}
return props;
}
}
IndexInfoCapability capability = repo.getCapability(IndexInfoCapability.class);
if (capability == null) {
return null;
}
IndexInfo info = null;
for (IndexInfo candidate : capability.getIndexInfo(type)) {
if (candidate.isClustered()) {
info = candidate;
break;
}
}
if (info == null) {
return null;
}
// Verify index is part of primary key.
Set<String> pkSet = StorableIntrospector.examine(type).getPrimaryKeyProperties().keySet();
String[] propNames = info.getPropertyNames();
for (String prop : propNames) {
if (!pkSet.contains(prop)) {
return null;
}
}
String[] orderBy = new String[pkSet.size()];
Direction[] directions = info.getPropertyDirections();
// Clone to remove elements.
pkSet = new LinkedHashSet<String>(pkSet);
int i;
for (i=0; i<propNames.length; i++) {
orderBy[i] = ((directions[i] == Direction.DESCENDING) ? "-" : "+") + propNames[i];
pkSet.remove(propNames[i]);
}
// Append any remaining pk properties, to ensure complete ordering.
if (pkSet.size() > 0) {
for (String prop : pkSet) {
orderBy[i++] = prop;
}
}
return orderBy;
}
|
[
"private",
"static",
"<",
"S",
"extends",
"Storable",
">",
"String",
"[",
"]",
"selectNaturalOrder",
"(",
"Repository",
"repo",
",",
"Class",
"<",
"S",
">",
"type",
",",
"Filter",
"<",
"S",
">",
"filter",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"!",
"filter",
".",
"isOpen",
"(",
")",
"&&",
"repo",
"instanceof",
"RepositoryAccess",
")",
"{",
"UnionQueryAnalyzer",
".",
"Result",
"result",
"=",
"new",
"UnionQueryAnalyzer",
"(",
"type",
",",
"(",
"RepositoryAccess",
")",
"repo",
")",
".",
"analyze",
"(",
"filter",
",",
"null",
",",
"QueryHints",
".",
"emptyHints",
"(",
")",
".",
"with",
"(",
"QueryHint",
".",
"CONSUME_SLICE",
")",
")",
";",
"OrderingList",
"<",
"S",
">",
"ordering",
"=",
"result",
".",
"getTotalOrdering",
"(",
")",
";",
"if",
"(",
"ordering",
"==",
"null",
")",
"{",
"List",
"<",
"IndexedQueryAnalyzer",
".",
"Result",
">",
"list",
"=",
"result",
".",
"getSubResults",
"(",
")",
";",
"if",
"(",
"!",
"list",
".",
"isEmpty",
"(",
")",
")",
"{",
"StorableIndex",
"<",
"S",
">",
"index",
"=",
"list",
".",
"get",
"(",
"0",
")",
".",
"getLocalIndex",
"(",
")",
";",
"if",
"(",
"index",
"!=",
"null",
")",
"{",
"ordering",
"=",
"OrderingList",
".",
"get",
"(",
"index",
".",
"getOrderedProperties",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"ordering",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"props",
"=",
"new",
"String",
"[",
"ordering",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"props",
".",
"length",
";",
"i",
"++",
")",
"{",
"props",
"[",
"i",
"]",
"=",
"ordering",
".",
"get",
"(",
"i",
")",
".",
"toString",
"(",
")",
";",
"}",
"return",
"props",
";",
"}",
"}",
"IndexInfoCapability",
"capability",
"=",
"repo",
".",
"getCapability",
"(",
"IndexInfoCapability",
".",
"class",
")",
";",
"if",
"(",
"capability",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"IndexInfo",
"info",
"=",
"null",
";",
"for",
"(",
"IndexInfo",
"candidate",
":",
"capability",
".",
"getIndexInfo",
"(",
"type",
")",
")",
"{",
"if",
"(",
"candidate",
".",
"isClustered",
"(",
")",
")",
"{",
"info",
"=",
"candidate",
";",
"break",
";",
"}",
"}",
"if",
"(",
"info",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// Verify index is part of primary key.\r",
"Set",
"<",
"String",
">",
"pkSet",
"=",
"StorableIntrospector",
".",
"examine",
"(",
"type",
")",
".",
"getPrimaryKeyProperties",
"(",
")",
".",
"keySet",
"(",
")",
";",
"String",
"[",
"]",
"propNames",
"=",
"info",
".",
"getPropertyNames",
"(",
")",
";",
"for",
"(",
"String",
"prop",
":",
"propNames",
")",
"{",
"if",
"(",
"!",
"pkSet",
".",
"contains",
"(",
"prop",
")",
")",
"{",
"return",
"null",
";",
"}",
"}",
"String",
"[",
"]",
"orderBy",
"=",
"new",
"String",
"[",
"pkSet",
".",
"size",
"(",
")",
"]",
";",
"Direction",
"[",
"]",
"directions",
"=",
"info",
".",
"getPropertyDirections",
"(",
")",
";",
"// Clone to remove elements.\r",
"pkSet",
"=",
"new",
"LinkedHashSet",
"<",
"String",
">",
"(",
"pkSet",
")",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"propNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"orderBy",
"[",
"i",
"]",
"=",
"(",
"(",
"directions",
"[",
"i",
"]",
"==",
"Direction",
".",
"DESCENDING",
")",
"?",
"\"-\"",
":",
"\"+\"",
")",
"+",
"propNames",
"[",
"i",
"]",
";",
"pkSet",
".",
"remove",
"(",
"propNames",
"[",
"i",
"]",
")",
";",
"}",
"// Append any remaining pk properties, to ensure complete ordering.\r",
"if",
"(",
"pkSet",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"String",
"prop",
":",
"pkSet",
")",
"{",
"orderBy",
"[",
"i",
"++",
"]",
"=",
"prop",
";",
"}",
"}",
"return",
"orderBy",
";",
"}"
] |
Utility method to select the natural ordering of a storage, by looking for a clustered
index on the primary key. Returns null if no clustered index was found. If a filter is
provided, the ordering which utilizes the best index is used.
|
[
"Utility",
"method",
"to",
"select",
"the",
"natural",
"ordering",
"of",
"a",
"storage",
"by",
"looking",
"for",
"a",
"clustered",
"index",
"on",
"the",
"primary",
"key",
".",
"Returns",
"null",
"if",
"no",
"clustered",
"index",
"was",
"found",
".",
"If",
"a",
"filter",
"is",
"provided",
"the",
"ordering",
"which",
"utilizes",
"the",
"best",
"index",
"is",
"used",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java#L101-L177
|
7,787 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.enter
|
public Transaction enter(IsolationLevel level) {
mLock.lock();
try {
TransactionImpl<Txn> parent = mActive;
IsolationLevel actualLevel = mTxnMgr.selectIsolationLevel(parent, level);
if (actualLevel == null) {
if (parent == null) {
throw new UnsupportedOperationException
("Desired isolation level not supported: " + level);
} else {
throw new UnsupportedOperationException
("Desired isolation level not supported: " + level
+ "; parent isolation level: " + parent.getIsolationLevel());
}
}
TransactionImpl<Txn> txn = new TransactionImpl<Txn>(this, parent, false, actualLevel);
mActive = txn;
mTxnMgr.entered(txn, parent);
return txn;
} finally {
mLock.unlock();
}
}
|
java
|
public Transaction enter(IsolationLevel level) {
mLock.lock();
try {
TransactionImpl<Txn> parent = mActive;
IsolationLevel actualLevel = mTxnMgr.selectIsolationLevel(parent, level);
if (actualLevel == null) {
if (parent == null) {
throw new UnsupportedOperationException
("Desired isolation level not supported: " + level);
} else {
throw new UnsupportedOperationException
("Desired isolation level not supported: " + level
+ "; parent isolation level: " + parent.getIsolationLevel());
}
}
TransactionImpl<Txn> txn = new TransactionImpl<Txn>(this, parent, false, actualLevel);
mActive = txn;
mTxnMgr.entered(txn, parent);
return txn;
} finally {
mLock.unlock();
}
}
|
[
"public",
"Transaction",
"enter",
"(",
"IsolationLevel",
"level",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"TransactionImpl",
"<",
"Txn",
">",
"parent",
"=",
"mActive",
";",
"IsolationLevel",
"actualLevel",
"=",
"mTxnMgr",
".",
"selectIsolationLevel",
"(",
"parent",
",",
"level",
")",
";",
"if",
"(",
"actualLevel",
"==",
"null",
")",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Desired isolation level not supported: \"",
"+",
"level",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Desired isolation level not supported: \"",
"+",
"level",
"+",
"\"; parent isolation level: \"",
"+",
"parent",
".",
"getIsolationLevel",
"(",
")",
")",
";",
"}",
"}",
"TransactionImpl",
"<",
"Txn",
">",
"txn",
"=",
"new",
"TransactionImpl",
"<",
"Txn",
">",
"(",
"this",
",",
"parent",
",",
"false",
",",
"actualLevel",
")",
";",
"mActive",
"=",
"txn",
";",
"mTxnMgr",
".",
"entered",
"(",
"txn",
",",
"parent",
")",
";",
"return",
"txn",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Enters a new transaction scope which becomes the active transaction.
@param level desired isolation level (may be null)
@throws UnsupportedOperationException if isolation level higher than
supported by repository
|
[
"Enters",
"a",
"new",
"transaction",
"scope",
"which",
"becomes",
"the",
"active",
"transaction",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L84-L109
|
7,788 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.enterTop
|
public Transaction enterTop(IsolationLevel level) {
mLock.lock();
try {
IsolationLevel actualLevel = mTxnMgr.selectIsolationLevel(null, level);
if (actualLevel == null) {
throw new UnsupportedOperationException
("Desired isolation level not supported: " + level);
}
TransactionImpl<Txn> txn = new TransactionImpl<Txn>(this, mActive, true, actualLevel);
mActive = txn;
mTxnMgr.entered(txn, null);
return txn;
} finally {
mLock.unlock();
}
}
|
java
|
public Transaction enterTop(IsolationLevel level) {
mLock.lock();
try {
IsolationLevel actualLevel = mTxnMgr.selectIsolationLevel(null, level);
if (actualLevel == null) {
throw new UnsupportedOperationException
("Desired isolation level not supported: " + level);
}
TransactionImpl<Txn> txn = new TransactionImpl<Txn>(this, mActive, true, actualLevel);
mActive = txn;
mTxnMgr.entered(txn, null);
return txn;
} finally {
mLock.unlock();
}
}
|
[
"public",
"Transaction",
"enterTop",
"(",
"IsolationLevel",
"level",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"IsolationLevel",
"actualLevel",
"=",
"mTxnMgr",
".",
"selectIsolationLevel",
"(",
"null",
",",
"level",
")",
";",
"if",
"(",
"actualLevel",
"==",
"null",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Desired isolation level not supported: \"",
"+",
"level",
")",
";",
"}",
"TransactionImpl",
"<",
"Txn",
">",
"txn",
"=",
"new",
"TransactionImpl",
"<",
"Txn",
">",
"(",
"this",
",",
"mActive",
",",
"true",
",",
"actualLevel",
")",
";",
"mActive",
"=",
"txn",
";",
"mTxnMgr",
".",
"entered",
"(",
"txn",
",",
"null",
")",
";",
"return",
"txn",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Enters a new top-level transaction scope which becomes the active
transaction.
@param level desired isolation level (may be null)
@throws UnsupportedOperationException if isolation level higher than
supported by repository
|
[
"Enters",
"a",
"new",
"top",
"-",
"level",
"transaction",
"scope",
"which",
"becomes",
"the",
"active",
"transaction",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L119-L137
|
7,789 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.exited
|
void exited(TransactionImpl<Txn> txn, TransactionImpl<Txn> active) {
mActive = active;
mTxnMgr.exited(txn, active);
}
|
java
|
void exited(TransactionImpl<Txn> txn, TransactionImpl<Txn> active) {
mActive = active;
mTxnMgr.exited(txn, active);
}
|
[
"void",
"exited",
"(",
"TransactionImpl",
"<",
"Txn",
">",
"txn",
",",
"TransactionImpl",
"<",
"Txn",
">",
"active",
")",
"{",
"mActive",
"=",
"active",
";",
"mTxnMgr",
".",
"exited",
"(",
"txn",
",",
"active",
")",
";",
"}"
] |
Called by TransactionImpl with lock held.
|
[
"Called",
"by",
"TransactionImpl",
"with",
"lock",
"held",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L140-L143
|
7,790 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.register
|
public <S extends Storable> void register(Class<S> type, Cursor<S> cursor) {
mLock.lock();
try {
checkClosed();
if (mCursors == null) {
mCursors = new IdentityHashMap<Class<?>, CursorList<TransactionImpl<Txn>>>();
}
CursorList<TransactionImpl<Txn>> cursorList = mCursors.get(type);
if (cursorList == null) {
cursorList = new CursorList<TransactionImpl<Txn>>();
mCursors.put(type, cursorList);
}
cursorList.register(cursor, mActive);
if (mActive != null) {
mActive.register(cursor);
}
} finally {
mLock.unlock();
}
}
|
java
|
public <S extends Storable> void register(Class<S> type, Cursor<S> cursor) {
mLock.lock();
try {
checkClosed();
if (mCursors == null) {
mCursors = new IdentityHashMap<Class<?>, CursorList<TransactionImpl<Txn>>>();
}
CursorList<TransactionImpl<Txn>> cursorList = mCursors.get(type);
if (cursorList == null) {
cursorList = new CursorList<TransactionImpl<Txn>>();
mCursors.put(type, cursorList);
}
cursorList.register(cursor, mActive);
if (mActive != null) {
mActive.register(cursor);
}
} finally {
mLock.unlock();
}
}
|
[
"public",
"<",
"S",
"extends",
"Storable",
">",
"void",
"register",
"(",
"Class",
"<",
"S",
">",
"type",
",",
"Cursor",
"<",
"S",
">",
"cursor",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"checkClosed",
"(",
")",
";",
"if",
"(",
"mCursors",
"==",
"null",
")",
"{",
"mCursors",
"=",
"new",
"IdentityHashMap",
"<",
"Class",
"<",
"?",
">",
",",
"CursorList",
"<",
"TransactionImpl",
"<",
"Txn",
">",
">",
">",
"(",
")",
";",
"}",
"CursorList",
"<",
"TransactionImpl",
"<",
"Txn",
">",
">",
"cursorList",
"=",
"mCursors",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"cursorList",
"==",
"null",
")",
"{",
"cursorList",
"=",
"new",
"CursorList",
"<",
"TransactionImpl",
"<",
"Txn",
">",
">",
"(",
")",
";",
"mCursors",
".",
"put",
"(",
"type",
",",
"cursorList",
")",
";",
"}",
"cursorList",
".",
"register",
"(",
"cursor",
",",
"mActive",
")",
";",
"if",
"(",
"mActive",
"!=",
"null",
")",
"{",
"mActive",
".",
"register",
"(",
"cursor",
")",
";",
"}",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Registers the given cursor against the active transaction, allowing it
to be closed on transaction exit or transaction manager close. If there
is no active transaction in scope, the cursor is registered as not part
of a transaction. Cursors should register when created.
|
[
"Registers",
"the",
"given",
"cursor",
"against",
"the",
"active",
"transaction",
"allowing",
"it",
"to",
"be",
"closed",
"on",
"transaction",
"exit",
"or",
"transaction",
"manager",
"close",
".",
"If",
"there",
"is",
"no",
"active",
"transaction",
"in",
"scope",
"the",
"cursor",
"is",
"registered",
"as",
"not",
"part",
"of",
"a",
"transaction",
".",
"Cursors",
"should",
"register",
"when",
"created",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L151-L173
|
7,791 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.unregister
|
public <S extends Storable> void unregister(Class<S> type, Cursor<S> cursor) {
mLock.lock();
try {
if (mCursors != null) {
CursorList<TransactionImpl<Txn>> cursorList = mCursors.get(type);
if (cursorList != null) {
TransactionImpl<Txn> txnImpl = cursorList.unregister(cursor);
if (txnImpl != null) {
txnImpl.unregister(cursor);
}
}
}
} finally {
mLock.unlock();
}
}
|
java
|
public <S extends Storable> void unregister(Class<S> type, Cursor<S> cursor) {
mLock.lock();
try {
if (mCursors != null) {
CursorList<TransactionImpl<Txn>> cursorList = mCursors.get(type);
if (cursorList != null) {
TransactionImpl<Txn> txnImpl = cursorList.unregister(cursor);
if (txnImpl != null) {
txnImpl.unregister(cursor);
}
}
}
} finally {
mLock.unlock();
}
}
|
[
"public",
"<",
"S",
"extends",
"Storable",
">",
"void",
"unregister",
"(",
"Class",
"<",
"S",
">",
"type",
",",
"Cursor",
"<",
"S",
">",
"cursor",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"mCursors",
"!=",
"null",
")",
"{",
"CursorList",
"<",
"TransactionImpl",
"<",
"Txn",
">>",
"cursorList",
"=",
"mCursors",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"cursorList",
"!=",
"null",
")",
"{",
"TransactionImpl",
"<",
"Txn",
">",
"txnImpl",
"=",
"cursorList",
".",
"unregister",
"(",
"cursor",
")",
";",
"if",
"(",
"txnImpl",
"!=",
"null",
")",
"{",
"txnImpl",
".",
"unregister",
"(",
"cursor",
")",
";",
"}",
"}",
"}",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Unregisters a previously registered cursor. Cursors should unregister
when closed.
|
[
"Unregisters",
"a",
"previously",
"registered",
"cursor",
".",
"Cursors",
"should",
"unregister",
"when",
"closed",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L179-L194
|
7,792 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.getTxn
|
public Txn getTxn() throws Exception {
mLock.lock();
try {
checkClosed();
return mActive == null ? null : mActive.getTxn();
} finally {
mLock.unlock();
}
}
|
java
|
public Txn getTxn() throws Exception {
mLock.lock();
try {
checkClosed();
return mActive == null ? null : mActive.getTxn();
} finally {
mLock.unlock();
}
}
|
[
"public",
"Txn",
"getTxn",
"(",
")",
"throws",
"Exception",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"checkClosed",
"(",
")",
";",
"return",
"mActive",
"==",
"null",
"?",
"null",
":",
"mActive",
".",
"getTxn",
"(",
")",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Returns the implementation for the active transaction, or null if there
is no active transaction.
@throws Exception thrown by createTxn or reuseTxn
|
[
"Returns",
"the",
"implementation",
"for",
"the",
"active",
"transaction",
"or",
"null",
"if",
"there",
"is",
"no",
"active",
"transaction",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L210-L218
|
7,793 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.isForUpdate
|
public boolean isForUpdate() {
mLock.lock();
try {
return (mClosed || mActive == null) ? false : mActive.isForUpdate();
} finally {
mLock.unlock();
}
}
|
java
|
public boolean isForUpdate() {
mLock.lock();
try {
return (mClosed || mActive == null) ? false : mActive.isForUpdate();
} finally {
mLock.unlock();
}
}
|
[
"public",
"boolean",
"isForUpdate",
"(",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"(",
"mClosed",
"||",
"mActive",
"==",
"null",
")",
"?",
"false",
":",
"mActive",
".",
"isForUpdate",
"(",
")",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Returns true if an active transaction exists and it is for update.
|
[
"Returns",
"true",
"if",
"an",
"active",
"transaction",
"exists",
"and",
"it",
"is",
"for",
"update",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L237-L244
|
7,794 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.getIsolationLevel
|
public IsolationLevel getIsolationLevel() {
mLock.lock();
try {
return (mClosed || mActive == null) ? null : mActive.getIsolationLevel();
} finally {
mLock.unlock();
}
}
|
java
|
public IsolationLevel getIsolationLevel() {
mLock.lock();
try {
return (mClosed || mActive == null) ? null : mActive.getIsolationLevel();
} finally {
mLock.unlock();
}
}
|
[
"public",
"IsolationLevel",
"getIsolationLevel",
"(",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"(",
"mClosed",
"||",
"mActive",
"==",
"null",
")",
"?",
"null",
":",
"mActive",
".",
"getIsolationLevel",
"(",
")",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Returns the isolation level of the active transaction, or null if there
is no active transaction.
|
[
"Returns",
"the",
"isolation",
"level",
"of",
"the",
"active",
"transaction",
"or",
"null",
"if",
"there",
"is",
"no",
"active",
"transaction",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L250-L257
|
7,795 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.detach
|
void detach() {
mLock.lock();
try {
if (mDetached || mTxnMgr.removeLocalScope(this)) {
mDetached = true;
} else {
throw new IllegalStateException("Transaction is attached to a different thread");
}
} finally {
mLock.unlock();
}
}
|
java
|
void detach() {
mLock.lock();
try {
if (mDetached || mTxnMgr.removeLocalScope(this)) {
mDetached = true;
} else {
throw new IllegalStateException("Transaction is attached to a different thread");
}
} finally {
mLock.unlock();
}
}
|
[
"void",
"detach",
"(",
")",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"mDetached",
"||",
"mTxnMgr",
".",
"removeLocalScope",
"(",
"this",
")",
")",
"{",
"mDetached",
"=",
"true",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Transaction is attached to a different thread\"",
")",
";",
"}",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Called by TransactionImpl.
|
[
"Called",
"by",
"TransactionImpl",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L283-L294
|
7,796 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/txn/TransactionScope.java
|
TransactionScope.close
|
void close() throws RepositoryException {
mLock.lock();
if (mClosed) {
mLock.unlock();
return;
}
Map<Class<?>, CursorList<TransactionImpl<Txn>>> cursors;
try {
cursors = mCursors;
// Ensure that map is freed promptly. Thread-local reference to
// this scope otherwise keeps map and its contents lingering around
// for a very long time.
mCursors = null;
while (mActive != null) {
mActive.exit();
}
} finally {
// Swap TransactionManager out with a dummy one, to allow the
// original one to get freed.
mTxnMgr = (TransactionManager<Txn>) TransactionManager.Closed.THE;
mClosed = true;
mLock.unlock();
}
// Close cursors without lock held, to prevent deadlock. Cursor close
// operation might acquire its own lock, which in turn acquires a lock
// on this scope.
if (cursors != null) {
for (CursorList<TransactionImpl<Txn>> cursorList : cursors.values()) {
cursorList.closeCursors();
}
}
}
|
java
|
void close() throws RepositoryException {
mLock.lock();
if (mClosed) {
mLock.unlock();
return;
}
Map<Class<?>, CursorList<TransactionImpl<Txn>>> cursors;
try {
cursors = mCursors;
// Ensure that map is freed promptly. Thread-local reference to
// this scope otherwise keeps map and its contents lingering around
// for a very long time.
mCursors = null;
while (mActive != null) {
mActive.exit();
}
} finally {
// Swap TransactionManager out with a dummy one, to allow the
// original one to get freed.
mTxnMgr = (TransactionManager<Txn>) TransactionManager.Closed.THE;
mClosed = true;
mLock.unlock();
}
// Close cursors without lock held, to prevent deadlock. Cursor close
// operation might acquire its own lock, which in turn acquires a lock
// on this scope.
if (cursors != null) {
for (CursorList<TransactionImpl<Txn>> cursorList : cursors.values()) {
cursorList.closeCursors();
}
}
}
|
[
"void",
"close",
"(",
")",
"throws",
"RepositoryException",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"if",
"(",
"mClosed",
")",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"return",
";",
"}",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"CursorList",
"<",
"TransactionImpl",
"<",
"Txn",
">",
">",
">",
"cursors",
";",
"try",
"{",
"cursors",
"=",
"mCursors",
";",
"// Ensure that map is freed promptly. Thread-local reference to\r",
"// this scope otherwise keeps map and its contents lingering around\r",
"// for a very long time.\r",
"mCursors",
"=",
"null",
";",
"while",
"(",
"mActive",
"!=",
"null",
")",
"{",
"mActive",
".",
"exit",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"// Swap TransactionManager out with a dummy one, to allow the\r",
"// original one to get freed.\r",
"mTxnMgr",
"=",
"(",
"TransactionManager",
"<",
"Txn",
">",
")",
"TransactionManager",
".",
"Closed",
".",
"THE",
";",
"mClosed",
"=",
"true",
";",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"// Close cursors without lock held, to prevent deadlock. Cursor close\r",
"// operation might acquire its own lock, which in turn acquires a lock\r",
"// on this scope.\r",
"if",
"(",
"cursors",
"!=",
"null",
")",
"{",
"for",
"(",
"CursorList",
"<",
"TransactionImpl",
"<",
"Txn",
">",
">",
"cursorList",
":",
"cursors",
".",
"values",
"(",
")",
")",
"{",
"cursorList",
".",
"closeCursors",
"(",
")",
";",
"}",
"}",
"}"
] |
Exits all transactions and closes all cursors. Should be called only
when repository is closed.
|
[
"Exits",
"all",
"transactions",
"and",
"closes",
"all",
"cursors",
".",
"Should",
"be",
"called",
"only",
"when",
"repository",
"is",
"closed",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionScope.java#L320-L355
|
7,797 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
|
StorableIndexSet.addKey
|
@SuppressWarnings("unchecked")
public void addKey(StorableKey<S> key) {
if (key == null) {
throw new IllegalArgumentException();
}
add(new StorableIndex<S>(key, Direction.UNSPECIFIED));
}
|
java
|
@SuppressWarnings("unchecked")
public void addKey(StorableKey<S> key) {
if (key == null) {
throw new IllegalArgumentException();
}
add(new StorableIndex<S>(key, Direction.UNSPECIFIED));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"addKey",
"(",
"StorableKey",
"<",
"S",
">",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"add",
"(",
"new",
"StorableIndex",
"<",
"S",
">",
"(",
"key",
",",
"Direction",
".",
"UNSPECIFIED",
")",
")",
";",
"}"
] |
Adds the key as a unique index, preserving the property arrangement.
@throws IllegalArgumentException if key is null
|
[
"Adds",
"the",
"key",
"as",
"a",
"unique",
"index",
"preserving",
"the",
"property",
"arrangement",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L131-L137
|
7,798 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
|
StorableIndexSet.reduce
|
public void reduce(Direction defaultDirection) {
List<StorableIndex<S>> group = new ArrayList<StorableIndex<S>>();
Map<StorableIndex<S>, StorableIndex<S>> mergedReplacements =
new TreeMap<StorableIndex<S>, StorableIndex<S>>(STORABLE_INDEX_COMPARATOR);
Iterator<StorableIndex<S>> it = iterator();
while (it.hasNext()) {
StorableIndex<S> candidate = it.next();
if (group.size() == 0 || isDifferentGroup(group.get(0), candidate)) {
group.clear();
group.add(candidate);
continue;
}
if (isRedundant(group, candidate, mergedReplacements)) {
it.remove();
} else {
group.add(candidate);
}
}
// Now replace merged indexes.
replaceEntries(mergedReplacements);
setDefaultDirection(defaultDirection);
}
|
java
|
public void reduce(Direction defaultDirection) {
List<StorableIndex<S>> group = new ArrayList<StorableIndex<S>>();
Map<StorableIndex<S>, StorableIndex<S>> mergedReplacements =
new TreeMap<StorableIndex<S>, StorableIndex<S>>(STORABLE_INDEX_COMPARATOR);
Iterator<StorableIndex<S>> it = iterator();
while (it.hasNext()) {
StorableIndex<S> candidate = it.next();
if (group.size() == 0 || isDifferentGroup(group.get(0), candidate)) {
group.clear();
group.add(candidate);
continue;
}
if (isRedundant(group, candidate, mergedReplacements)) {
it.remove();
} else {
group.add(candidate);
}
}
// Now replace merged indexes.
replaceEntries(mergedReplacements);
setDefaultDirection(defaultDirection);
}
|
[
"public",
"void",
"reduce",
"(",
"Direction",
"defaultDirection",
")",
"{",
"List",
"<",
"StorableIndex",
"<",
"S",
">>",
"group",
"=",
"new",
"ArrayList",
"<",
"StorableIndex",
"<",
"S",
">",
">",
"(",
")",
";",
"Map",
"<",
"StorableIndex",
"<",
"S",
">",
",",
"StorableIndex",
"<",
"S",
">",
">",
"mergedReplacements",
"=",
"new",
"TreeMap",
"<",
"StorableIndex",
"<",
"S",
">",
",",
"StorableIndex",
"<",
"S",
">",
">",
"(",
"STORABLE_INDEX_COMPARATOR",
")",
";",
"Iterator",
"<",
"StorableIndex",
"<",
"S",
">",
">",
"it",
"=",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"StorableIndex",
"<",
"S",
">",
"candidate",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"group",
".",
"size",
"(",
")",
"==",
"0",
"||",
"isDifferentGroup",
"(",
"group",
".",
"get",
"(",
"0",
")",
",",
"candidate",
")",
")",
"{",
"group",
".",
"clear",
"(",
")",
";",
"group",
".",
"add",
"(",
"candidate",
")",
";",
"continue",
";",
"}",
"if",
"(",
"isRedundant",
"(",
"group",
",",
"candidate",
",",
"mergedReplacements",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"else",
"{",
"group",
".",
"add",
"(",
"candidate",
")",
";",
"}",
"}",
"// Now replace merged indexes.\r",
"replaceEntries",
"(",
"mergedReplacements",
")",
";",
"setDefaultDirection",
"(",
"defaultDirection",
")",
";",
"}"
] |
Reduces the size of the set by removing redundant indexes, and merges
others together.
@param defaultDirection replace unspecified property directions with this
|
[
"Reduces",
"the",
"size",
"of",
"the",
"set",
"by",
"removing",
"redundant",
"indexes",
"and",
"merges",
"others",
"together",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L153-L179
|
7,799 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
|
StorableIndexSet.setDefaultDirection
|
public void setDefaultDirection(Direction defaultDirection) {
// Apply default sort direction to those unspecified.
if (defaultDirection != Direction.UNSPECIFIED) {
Map<StorableIndex<S>, StorableIndex<S>> replacements = null;
for (StorableIndex<S> index : this) {
StorableIndex<S> replacement = index.setDefaultDirection(defaultDirection);
if (replacement != index) {
if (replacements == null) {
replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>();
}
replacements.put(index, replacement);
}
}
replaceEntries(replacements);
}
}
|
java
|
public void setDefaultDirection(Direction defaultDirection) {
// Apply default sort direction to those unspecified.
if (defaultDirection != Direction.UNSPECIFIED) {
Map<StorableIndex<S>, StorableIndex<S>> replacements = null;
for (StorableIndex<S> index : this) {
StorableIndex<S> replacement = index.setDefaultDirection(defaultDirection);
if (replacement != index) {
if (replacements == null) {
replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>();
}
replacements.put(index, replacement);
}
}
replaceEntries(replacements);
}
}
|
[
"public",
"void",
"setDefaultDirection",
"(",
"Direction",
"defaultDirection",
")",
"{",
"// Apply default sort direction to those unspecified.\r",
"if",
"(",
"defaultDirection",
"!=",
"Direction",
".",
"UNSPECIFIED",
")",
"{",
"Map",
"<",
"StorableIndex",
"<",
"S",
">",
",",
"StorableIndex",
"<",
"S",
">",
">",
"replacements",
"=",
"null",
";",
"for",
"(",
"StorableIndex",
"<",
"S",
">",
"index",
":",
"this",
")",
"{",
"StorableIndex",
"<",
"S",
">",
"replacement",
"=",
"index",
".",
"setDefaultDirection",
"(",
"defaultDirection",
")",
";",
"if",
"(",
"replacement",
"!=",
"index",
")",
"{",
"if",
"(",
"replacements",
"==",
"null",
")",
"{",
"replacements",
"=",
"new",
"HashMap",
"<",
"StorableIndex",
"<",
"S",
">",
",",
"StorableIndex",
"<",
"S",
">",
">",
"(",
")",
";",
"}",
"replacements",
".",
"put",
"(",
"index",
",",
"replacement",
")",
";",
"}",
"}",
"replaceEntries",
"(",
"replacements",
")",
";",
"}",
"}"
] |
Set the default direction for all index properties.
@param defaultDirection replace unspecified property directions with this
|
[
"Set",
"the",
"default",
"direction",
"for",
"all",
"index",
"properties",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L186-L201
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.