repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
geomajas/geomajas-project-server | plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/filter/ExtendedLikeFilterImpl.java | ExtendedLikeFilterImpl.isSpecial | private boolean isSpecial(final char chr) {
return ((chr == '.') || (chr == '?') || (chr == '*') || (chr == '^') || (chr == '$') || (chr == '+')
|| (chr == '[') || (chr == ']') || (chr == '(') || (chr == ')') || (chr == '|') || (chr == '\\')
|| (chr == '&'));
} | java | private boolean isSpecial(final char chr) {
return ((chr == '.') || (chr == '?') || (chr == '*') || (chr == '^') || (chr == '$') || (chr == '+')
|| (chr == '[') || (chr == ']') || (chr == '(') || (chr == ')') || (chr == '|') || (chr == '\\')
|| (chr == '&'));
} | [
"private",
"boolean",
"isSpecial",
"(",
"final",
"char",
"chr",
")",
"{",
"return",
"(",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
"||",
"(",
"chr",
"==",
"'",
"'",
")",
")",
";",
"}"
] | Convenience method to determine if a character is special to the regex system.
@param chr
the character to test
@return is the character a special character. | [
"Convenience",
"method",
"to",
"determine",
"if",
"a",
"character",
"is",
"special",
"to",
"the",
"regex",
"system",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/filter/ExtendedLikeFilterImpl.java#L473-L477 | train |
geomajas/geomajas-project-server | plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/filter/ExtendedLikeFilterImpl.java | ExtendedLikeFilterImpl.fixSpecials | private String fixSpecials(final String inString) {
StringBuilder tmp = new StringBuilder();
for (int i = 0; i < inString.length(); i++) {
char chr = inString.charAt(i);
if (isSpecial(chr)) {
tmp.append(this.escape);
tmp.append(chr);
} else {
tmp.append(chr);
}
}
return tmp.toString();
} | java | private String fixSpecials(final String inString) {
StringBuilder tmp = new StringBuilder();
for (int i = 0; i < inString.length(); i++) {
char chr = inString.charAt(i);
if (isSpecial(chr)) {
tmp.append(this.escape);
tmp.append(chr);
} else {
tmp.append(chr);
}
}
return tmp.toString();
} | [
"private",
"String",
"fixSpecials",
"(",
"final",
"String",
"inString",
")",
"{",
"StringBuilder",
"tmp",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"inString",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"chr",
"=",
"inString",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"isSpecial",
"(",
"chr",
")",
")",
"{",
"tmp",
".",
"append",
"(",
"this",
".",
"escape",
")",
";",
"tmp",
".",
"append",
"(",
"chr",
")",
";",
"}",
"else",
"{",
"tmp",
".",
"append",
"(",
"chr",
")",
";",
"}",
"}",
"return",
"tmp",
".",
"toString",
"(",
")",
";",
"}"
] | Convenience method to escape any character that is special to the regex system.
@param inString
the string to fix
@return the fixed string | [
"Convenience",
"method",
"to",
"escape",
"any",
"character",
"that",
"is",
"special",
"to",
"the",
"regex",
"system",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-hibernate/hibernate/src/main/java/org/geomajas/layer/hibernate/filter/ExtendedLikeFilterImpl.java#L487-L502 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java | StatementsForClassImpl.prepareStatement | protected PreparedStatement prepareStatement(Connection con,
String sql,
boolean scrollable,
boolean createPreparedStatement,
int explicitFetchSizeHint)
throws SQLException
{
PreparedStatement result;
// if a JDBC1.0 driver is used the signature
// prepareStatement(String, int, int) is not defined.
// we then call the JDBC1.0 variant prepareStatement(String)
try
{
// if necessary use JDB1.0 methods
if (!FORCEJDBC1_0)
{
if (createPreparedStatement)
{
result =
con.prepareStatement(
sql,
scrollable
? ResultSet.TYPE_SCROLL_INSENSITIVE
: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
afterJdbc2CapableStatementCreate(result, explicitFetchSizeHint);
}
else
{
result =
con.prepareCall(
sql,
scrollable
? ResultSet.TYPE_SCROLL_INSENSITIVE
: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
}
}
else
{
if (createPreparedStatement)
{
result = con.prepareStatement(sql);
}
else
{
result = con.prepareCall(sql);
}
}
}
catch (AbstractMethodError err)
{
// this exception is raised if Driver is not JDBC 2.0 compliant
log.warn("Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode", err);
if (createPreparedStatement)
{
result = con.prepareStatement(sql);
}
else
{
result = con.prepareCall(sql);
}
FORCEJDBC1_0 = true;
}
catch (SQLException eSql)
{
// there are JDBC Driver that nominally implement JDBC 2.0, but
// throw DriverNotCapableExceptions. If we catch one of these
// we force usage of JDBC 1.0
if (eSql
.getClass()
.getName()
.equals("interbase.interclient.DriverNotCapableException"))
{
log.warn("JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode");
if (createPreparedStatement)
{
result = con.prepareStatement(sql);
}
else
{
result = con.prepareCall(sql);
}
FORCEJDBC1_0 = true;
}
else
{
throw eSql;
}
}
try
{
if (!ProxyHelper.isNormalOjbProxy(result)) // tomdz: What about VirtualProxy
{
platform.afterStatementCreate(result);
}
}
catch (PlatformException e)
{
log.error("Platform dependend failure", e);
}
return result;
} | java | protected PreparedStatement prepareStatement(Connection con,
String sql,
boolean scrollable,
boolean createPreparedStatement,
int explicitFetchSizeHint)
throws SQLException
{
PreparedStatement result;
// if a JDBC1.0 driver is used the signature
// prepareStatement(String, int, int) is not defined.
// we then call the JDBC1.0 variant prepareStatement(String)
try
{
// if necessary use JDB1.0 methods
if (!FORCEJDBC1_0)
{
if (createPreparedStatement)
{
result =
con.prepareStatement(
sql,
scrollable
? ResultSet.TYPE_SCROLL_INSENSITIVE
: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
afterJdbc2CapableStatementCreate(result, explicitFetchSizeHint);
}
else
{
result =
con.prepareCall(
sql,
scrollable
? ResultSet.TYPE_SCROLL_INSENSITIVE
: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
}
}
else
{
if (createPreparedStatement)
{
result = con.prepareStatement(sql);
}
else
{
result = con.prepareCall(sql);
}
}
}
catch (AbstractMethodError err)
{
// this exception is raised if Driver is not JDBC 2.0 compliant
log.warn("Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode", err);
if (createPreparedStatement)
{
result = con.prepareStatement(sql);
}
else
{
result = con.prepareCall(sql);
}
FORCEJDBC1_0 = true;
}
catch (SQLException eSql)
{
// there are JDBC Driver that nominally implement JDBC 2.0, but
// throw DriverNotCapableExceptions. If we catch one of these
// we force usage of JDBC 1.0
if (eSql
.getClass()
.getName()
.equals("interbase.interclient.DriverNotCapableException"))
{
log.warn("JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode");
if (createPreparedStatement)
{
result = con.prepareStatement(sql);
}
else
{
result = con.prepareCall(sql);
}
FORCEJDBC1_0 = true;
}
else
{
throw eSql;
}
}
try
{
if (!ProxyHelper.isNormalOjbProxy(result)) // tomdz: What about VirtualProxy
{
platform.afterStatementCreate(result);
}
}
catch (PlatformException e)
{
log.error("Platform dependend failure", e);
}
return result;
} | [
"protected",
"PreparedStatement",
"prepareStatement",
"(",
"Connection",
"con",
",",
"String",
"sql",
",",
"boolean",
"scrollable",
",",
"boolean",
"createPreparedStatement",
",",
"int",
"explicitFetchSizeHint",
")",
"throws",
"SQLException",
"{",
"PreparedStatement",
"result",
";",
"// if a JDBC1.0 driver is used the signature\r",
"// prepareStatement(String, int, int) is not defined.\r",
"// we then call the JDBC1.0 variant prepareStatement(String)\r",
"try",
"{",
"// if necessary use JDB1.0 methods\r",
"if",
"(",
"!",
"FORCEJDBC1_0",
")",
"{",
"if",
"(",
"createPreparedStatement",
")",
"{",
"result",
"=",
"con",
".",
"prepareStatement",
"(",
"sql",
",",
"scrollable",
"?",
"ResultSet",
".",
"TYPE_SCROLL_INSENSITIVE",
":",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
".",
"CONCUR_READ_ONLY",
")",
";",
"afterJdbc2CapableStatementCreate",
"(",
"result",
",",
"explicitFetchSizeHint",
")",
";",
"}",
"else",
"{",
"result",
"=",
"con",
".",
"prepareCall",
"(",
"sql",
",",
"scrollable",
"?",
"ResultSet",
".",
"TYPE_SCROLL_INSENSITIVE",
":",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
".",
"CONCUR_READ_ONLY",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"createPreparedStatement",
")",
"{",
"result",
"=",
"con",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"}",
"else",
"{",
"result",
"=",
"con",
".",
"prepareCall",
"(",
"sql",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"AbstractMethodError",
"err",
")",
"{",
"// this exception is raised if Driver is not JDBC 2.0 compliant\r",
"log",
".",
"warn",
"(",
"\"Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode\"",
",",
"err",
")",
";",
"if",
"(",
"createPreparedStatement",
")",
"{",
"result",
"=",
"con",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"}",
"else",
"{",
"result",
"=",
"con",
".",
"prepareCall",
"(",
"sql",
")",
";",
"}",
"FORCEJDBC1_0",
"=",
"true",
";",
"}",
"catch",
"(",
"SQLException",
"eSql",
")",
"{",
"// there are JDBC Driver that nominally implement JDBC 2.0, but\r",
"// throw DriverNotCapableExceptions. If we catch one of these\r",
"// we force usage of JDBC 1.0\r",
"if",
"(",
"eSql",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"interbase.interclient.DriverNotCapableException\"",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode\"",
")",
";",
"if",
"(",
"createPreparedStatement",
")",
"{",
"result",
"=",
"con",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"}",
"else",
"{",
"result",
"=",
"con",
".",
"prepareCall",
"(",
"sql",
")",
";",
"}",
"FORCEJDBC1_0",
"=",
"true",
";",
"}",
"else",
"{",
"throw",
"eSql",
";",
"}",
"}",
"try",
"{",
"if",
"(",
"!",
"ProxyHelper",
".",
"isNormalOjbProxy",
"(",
"result",
")",
")",
"// tomdz: What about VirtualProxy\r",
"{",
"platform",
".",
"afterStatementCreate",
"(",
"result",
")",
";",
"}",
"}",
"catch",
"(",
"PlatformException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Platform dependend failure\"",
",",
"e",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Prepares a statement with parameters that should work with most RDBMS.
@param con the connection to utilize
@param sql the sql syntax to use when creating the statement.
@param scrollable determines if the statement will be scrollable.
@param createPreparedStatement if <code>true</code>, then a
{@link PreparedStatement} will be created. If <code>false</code>, then
a {@link java.sql.CallableStatement} will be created.
@param explicitFetchSizeHint will be used as fetchSize hint
(if applicable) if > 0
@return a statement that can be used to execute the syntax contained in
the <code>sql</code> argument. | [
"Prepares",
"a",
"statement",
"with",
"parameters",
"that",
"should",
"work",
"with",
"most",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java#L244-L347 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java | StatementsForClassImpl.createStatement | private Statement createStatement(Connection con, boolean scrollable, int explicitFetchSizeHint)
throws java.sql.SQLException
{
Statement result;
try
{
// if necessary use JDBC1.0 methods
if (!FORCEJDBC1_0)
{
result =
con.createStatement(
scrollable
? ResultSet.TYPE_SCROLL_INSENSITIVE
: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
afterJdbc2CapableStatementCreate(result, explicitFetchSizeHint);
}
else
{
result = con.createStatement();
}
}
catch (AbstractMethodError err)
{
// if a JDBC1.0 driver is used, the signature
// createStatement(int, int) is not defined.
// we then call the JDBC1.0 variant createStatement()
log.warn("Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode", err);
result = con.createStatement();
FORCEJDBC1_0 = true;
}
catch (SQLException eSql)
{
// there are JDBC Driver that nominally implement JDBC 2.0, but
// throw DriverNotCapableExceptions. If we catch one of these
// we force usage of JDBC 1.0
if (eSql.getClass().getName()
.equals("interbase.interclient.DriverNotCapableException"))
{
log.warn("JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode");
FORCEJDBC1_0 = true;
result = con.createStatement();
}
else
{
throw eSql;
}
}
try
{
platform.afterStatementCreate(result);
}
catch (PlatformException e)
{
log.error("Platform dependend failure", e);
}
return result;
} | java | private Statement createStatement(Connection con, boolean scrollable, int explicitFetchSizeHint)
throws java.sql.SQLException
{
Statement result;
try
{
// if necessary use JDBC1.0 methods
if (!FORCEJDBC1_0)
{
result =
con.createStatement(
scrollable
? ResultSet.TYPE_SCROLL_INSENSITIVE
: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
afterJdbc2CapableStatementCreate(result, explicitFetchSizeHint);
}
else
{
result = con.createStatement();
}
}
catch (AbstractMethodError err)
{
// if a JDBC1.0 driver is used, the signature
// createStatement(int, int) is not defined.
// we then call the JDBC1.0 variant createStatement()
log.warn("Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode", err);
result = con.createStatement();
FORCEJDBC1_0 = true;
}
catch (SQLException eSql)
{
// there are JDBC Driver that nominally implement JDBC 2.0, but
// throw DriverNotCapableExceptions. If we catch one of these
// we force usage of JDBC 1.0
if (eSql.getClass().getName()
.equals("interbase.interclient.DriverNotCapableException"))
{
log.warn("JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode");
FORCEJDBC1_0 = true;
result = con.createStatement();
}
else
{
throw eSql;
}
}
try
{
platform.afterStatementCreate(result);
}
catch (PlatformException e)
{
log.error("Platform dependend failure", e);
}
return result;
} | [
"private",
"Statement",
"createStatement",
"(",
"Connection",
"con",
",",
"boolean",
"scrollable",
",",
"int",
"explicitFetchSizeHint",
")",
"throws",
"java",
".",
"sql",
".",
"SQLException",
"{",
"Statement",
"result",
";",
"try",
"{",
"// if necessary use JDBC1.0 methods\r",
"if",
"(",
"!",
"FORCEJDBC1_0",
")",
"{",
"result",
"=",
"con",
".",
"createStatement",
"(",
"scrollable",
"?",
"ResultSet",
".",
"TYPE_SCROLL_INSENSITIVE",
":",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
".",
"CONCUR_READ_ONLY",
")",
";",
"afterJdbc2CapableStatementCreate",
"(",
"result",
",",
"explicitFetchSizeHint",
")",
";",
"}",
"else",
"{",
"result",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"AbstractMethodError",
"err",
")",
"{",
"// if a JDBC1.0 driver is used, the signature\r",
"// createStatement(int, int) is not defined.\r",
"// we then call the JDBC1.0 variant createStatement()\r",
"log",
".",
"warn",
"(",
"\"Used driver seems not JDBC 2.0 compatible, use the JDBC 1.0 mode\"",
",",
"err",
")",
";",
"result",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"FORCEJDBC1_0",
"=",
"true",
";",
"}",
"catch",
"(",
"SQLException",
"eSql",
")",
"{",
"// there are JDBC Driver that nominally implement JDBC 2.0, but\r",
"// throw DriverNotCapableExceptions. If we catch one of these\r",
"// we force usage of JDBC 1.0\r",
"if",
"(",
"eSql",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"interbase.interclient.DriverNotCapableException\"",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"JDBC 2.0 problems with this interbase driver, we use the JDBC 1.0 mode\"",
")",
";",
"FORCEJDBC1_0",
"=",
"true",
";",
"result",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"eSql",
";",
"}",
"}",
"try",
"{",
"platform",
".",
"afterStatementCreate",
"(",
"result",
")",
";",
"}",
"catch",
"(",
"PlatformException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Platform dependend failure\"",
",",
"e",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Creates a statement with parameters that should work with most RDBMS. | [
"Creates",
"a",
"statement",
"with",
"parameters",
"that",
"should",
"work",
"with",
"most",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java#L352-L409 | train |
geomajas/geomajas-project-server | impl/src/main/java/org/geomajas/internal/layer/feature/InternalFeatureImpl.java | InternalFeatureImpl.compareTo | public int compareTo(InternalFeature o) {
if (null == o) {
return -1; // avoid NPE, put null objects at the end
}
if (null != styleDefinition && null != o.getStyleInfo()) {
if (styleDefinition.getIndex() > o.getStyleInfo().getIndex()) {
return 1;
}
if (styleDefinition.getIndex() < o.getStyleInfo().getIndex()) {
return -1;
}
}
return 0;
} | java | public int compareTo(InternalFeature o) {
if (null == o) {
return -1; // avoid NPE, put null objects at the end
}
if (null != styleDefinition && null != o.getStyleInfo()) {
if (styleDefinition.getIndex() > o.getStyleInfo().getIndex()) {
return 1;
}
if (styleDefinition.getIndex() < o.getStyleInfo().getIndex()) {
return -1;
}
}
return 0;
} | [
"public",
"int",
"compareTo",
"(",
"InternalFeature",
"o",
")",
"{",
"if",
"(",
"null",
"==",
"o",
")",
"{",
"return",
"-",
"1",
";",
"// avoid NPE, put null objects at the end",
"}",
"if",
"(",
"null",
"!=",
"styleDefinition",
"&&",
"null",
"!=",
"o",
".",
"getStyleInfo",
"(",
")",
")",
"{",
"if",
"(",
"styleDefinition",
".",
"getIndex",
"(",
")",
">",
"o",
".",
"getStyleInfo",
"(",
")",
".",
"getIndex",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"styleDefinition",
".",
"getIndex",
"(",
")",
"<",
"o",
".",
"getStyleInfo",
"(",
")",
".",
"getIndex",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | This function compares style ID's between features. Features are usually sorted by style. | [
"This",
"function",
"compares",
"style",
"ID",
"s",
"between",
"features",
".",
"Features",
"are",
"usually",
"sorted",
"by",
"style",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/internal/layer/feature/InternalFeatureImpl.java#L126-L139 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/AbstractLogFileScavenger.java | AbstractLogFileScavenger.begin | public final void begin() {
this.file = this.getAppender().getIoFile();
if (this.file == null) {
this.getAppender().getErrorHandler()
.error("Scavenger not started: missing log file name");
return;
}
if (this.getProperties().getScavengeInterval() > -1) {
final Thread thread = new Thread(this, "Log4J File Scavenger");
thread.setDaemon(true);
thread.start();
this.threadRef = thread;
}
} | java | public final void begin() {
this.file = this.getAppender().getIoFile();
if (this.file == null) {
this.getAppender().getErrorHandler()
.error("Scavenger not started: missing log file name");
return;
}
if (this.getProperties().getScavengeInterval() > -1) {
final Thread thread = new Thread(this, "Log4J File Scavenger");
thread.setDaemon(true);
thread.start();
this.threadRef = thread;
}
} | [
"public",
"final",
"void",
"begin",
"(",
")",
"{",
"this",
".",
"file",
"=",
"this",
".",
"getAppender",
"(",
")",
".",
"getIoFile",
"(",
")",
";",
"if",
"(",
"this",
".",
"file",
"==",
"null",
")",
"{",
"this",
".",
"getAppender",
"(",
")",
".",
"getErrorHandler",
"(",
")",
".",
"error",
"(",
"\"Scavenger not started: missing log file name\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"this",
".",
"getProperties",
"(",
")",
".",
"getScavengeInterval",
"(",
")",
">",
"-",
"1",
")",
"{",
"final",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"this",
",",
"\"Log4J File Scavenger\"",
")",
";",
"thread",
".",
"setDaemon",
"(",
"true",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"this",
".",
"threadRef",
"=",
"thread",
";",
"}",
"}"
] | Starts the scavenger. | [
"Starts",
"the",
"scavenger",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/AbstractLogFileScavenger.java#L54-L67 | train |
foundation-runtime/logging | logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/AbstractLogFileScavenger.java | AbstractLogFileScavenger.end | public final void end() {
final Thread thread = threadRef;
if (thread != null) {
thread.interrupt();
try {
thread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
this.threadRef = null;
} | java | public final void end() {
final Thread thread = threadRef;
if (thread != null) {
thread.interrupt();
try {
thread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
this.threadRef = null;
} | [
"public",
"final",
"void",
"end",
"(",
")",
"{",
"final",
"Thread",
"thread",
"=",
"threadRef",
";",
"if",
"(",
"thread",
"!=",
"null",
")",
"{",
"thread",
".",
"interrupt",
"(",
")",
";",
"try",
"{",
"thread",
".",
"join",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}",
"this",
".",
"threadRef",
"=",
"null",
";",
"}"
] | Stops the scavenger. | [
"Stops",
"the",
"scavenger",
"."
] | cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6 | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/appender/AbstractLogFileScavenger.java#L72-L83 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java | PropertyHelper.isPropertyAllowed | public static boolean isPropertyAllowed(Class defClass, String propertyName)
{
HashMap props = (HashMap)_properties.get(defClass);
return (props == null ? true : props.containsKey(propertyName));
} | java | public static boolean isPropertyAllowed(Class defClass, String propertyName)
{
HashMap props = (HashMap)_properties.get(defClass);
return (props == null ? true : props.containsKey(propertyName));
} | [
"public",
"static",
"boolean",
"isPropertyAllowed",
"(",
"Class",
"defClass",
",",
"String",
"propertyName",
")",
"{",
"HashMap",
"props",
"=",
"(",
"HashMap",
")",
"_properties",
".",
"get",
"(",
"defClass",
")",
";",
"return",
"(",
"props",
"==",
"null",
"?",
"true",
":",
"props",
".",
"containsKey",
"(",
"propertyName",
")",
")",
";",
"}"
] | Checks whether the property of the given name is allowed for the model element.
@param defClass The class of the model element
@param propertyName The name of the property
@return <code>true</code> if the property is allowed for this type of model elements | [
"Checks",
"whether",
"the",
"property",
"of",
"the",
"given",
"name",
"is",
"allowed",
"for",
"the",
"model",
"element",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java#L242-L247 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java | PropertyHelper.toBoolean | public static boolean toBoolean(String value, boolean defaultValue)
{
return "true".equals(value) ? true : ("false".equals(value) ? false : defaultValue);
} | java | public static boolean toBoolean(String value, boolean defaultValue)
{
return "true".equals(value) ? true : ("false".equals(value) ? false : defaultValue);
} | [
"public",
"static",
"boolean",
"toBoolean",
"(",
"String",
"value",
",",
"boolean",
"defaultValue",
")",
"{",
"return",
"\"true\"",
".",
"equals",
"(",
"value",
")",
"?",
"true",
":",
"(",
"\"false\"",
".",
"equals",
"(",
"value",
")",
"?",
"false",
":",
"defaultValue",
")",
";",
"}"
] | Determines whether the boolean value of the given string value.
@param value The value
@param defaultValue The boolean value to use if the string value is neither 'true' nor 'false'
@return The boolean value of the string | [
"Determines",
"whether",
"the",
"boolean",
"value",
"of",
"the",
"given",
"string",
"value",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java#L256-L259 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getFieldDescriptor | protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, PathInfo aPathInfo)
{
FieldDescriptor fld = null;
String colName = aPathInfo.column;
if (aTableAlias != null)
{
fld = aTableAlias.cld.getFieldDescriptorByName(colName);
if (fld == null)
{
ObjectReferenceDescriptor ord = aTableAlias.cld.getObjectReferenceDescriptorByName(colName);
if (ord != null)
{
fld = getFldFromReference(aTableAlias, ord);
}
else
{
fld = getFldFromJoin(aTableAlias, colName);
}
}
}
return fld;
} | java | protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, PathInfo aPathInfo)
{
FieldDescriptor fld = null;
String colName = aPathInfo.column;
if (aTableAlias != null)
{
fld = aTableAlias.cld.getFieldDescriptorByName(colName);
if (fld == null)
{
ObjectReferenceDescriptor ord = aTableAlias.cld.getObjectReferenceDescriptorByName(colName);
if (ord != null)
{
fld = getFldFromReference(aTableAlias, ord);
}
else
{
fld = getFldFromJoin(aTableAlias, colName);
}
}
}
return fld;
} | [
"protected",
"FieldDescriptor",
"getFieldDescriptor",
"(",
"TableAlias",
"aTableAlias",
",",
"PathInfo",
"aPathInfo",
")",
"{",
"FieldDescriptor",
"fld",
"=",
"null",
";",
"String",
"colName",
"=",
"aPathInfo",
".",
"column",
";",
"if",
"(",
"aTableAlias",
"!=",
"null",
")",
"{",
"fld",
"=",
"aTableAlias",
".",
"cld",
".",
"getFieldDescriptorByName",
"(",
"colName",
")",
";",
"if",
"(",
"fld",
"==",
"null",
")",
"{",
"ObjectReferenceDescriptor",
"ord",
"=",
"aTableAlias",
".",
"cld",
".",
"getObjectReferenceDescriptorByName",
"(",
"colName",
")",
";",
"if",
"(",
"ord",
"!=",
"null",
")",
"{",
"fld",
"=",
"getFldFromReference",
"(",
"aTableAlias",
",",
"ord",
")",
";",
"}",
"else",
"{",
"fld",
"=",
"getFldFromJoin",
"(",
"aTableAlias",
",",
"colName",
")",
";",
"}",
"}",
"}",
"return",
"fld",
";",
"}"
] | Get the FieldDescriptor for the PathInfo
@param aTableAlias
@param aPathInfo
@return FieldDescriptor | [
"Get",
"the",
"FieldDescriptor",
"for",
"the",
"PathInfo"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L342-L365 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getFldFromJoin | private FieldDescriptor getFldFromJoin(TableAlias aTableAlias, String aColName)
{
FieldDescriptor fld = null;
// Search Join Structure for attribute
if (aTableAlias.joins != null)
{
Iterator itr = aTableAlias.joins.iterator();
while (itr.hasNext())
{
Join join = (Join) itr.next();
ClassDescriptor cld = join.right.cld;
if (cld != null)
{
fld = cld.getFieldDescriptorByName(aColName);
if (fld != null)
{
break;
}
}
}
}
return fld;
} | java | private FieldDescriptor getFldFromJoin(TableAlias aTableAlias, String aColName)
{
FieldDescriptor fld = null;
// Search Join Structure for attribute
if (aTableAlias.joins != null)
{
Iterator itr = aTableAlias.joins.iterator();
while (itr.hasNext())
{
Join join = (Join) itr.next();
ClassDescriptor cld = join.right.cld;
if (cld != null)
{
fld = cld.getFieldDescriptorByName(aColName);
if (fld != null)
{
break;
}
}
}
}
return fld;
} | [
"private",
"FieldDescriptor",
"getFldFromJoin",
"(",
"TableAlias",
"aTableAlias",
",",
"String",
"aColName",
")",
"{",
"FieldDescriptor",
"fld",
"=",
"null",
";",
"// Search Join Structure for attribute\r",
"if",
"(",
"aTableAlias",
".",
"joins",
"!=",
"null",
")",
"{",
"Iterator",
"itr",
"=",
"aTableAlias",
".",
"joins",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"itr",
".",
"hasNext",
"(",
")",
")",
"{",
"Join",
"join",
"=",
"(",
"Join",
")",
"itr",
".",
"next",
"(",
")",
";",
"ClassDescriptor",
"cld",
"=",
"join",
".",
"right",
".",
"cld",
";",
"if",
"(",
"cld",
"!=",
"null",
")",
"{",
"fld",
"=",
"cld",
".",
"getFieldDescriptorByName",
"(",
"aColName",
")",
";",
"if",
"(",
"fld",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"fld",
";",
"}"
] | Get FieldDescriptor from joined superclass. | [
"Get",
"FieldDescriptor",
"from",
"joined",
"superclass",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L370-L395 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getFldFromReference | private FieldDescriptor getFldFromReference(TableAlias aTableAlias, ObjectReferenceDescriptor anOrd)
{
FieldDescriptor fld = null;
if (aTableAlias == getRoot())
{
// no path expression
FieldDescriptor[] fk = anOrd.getForeignKeyFieldDescriptors(aTableAlias.cld);
if (fk.length > 0)
{
fld = fk[0];
}
}
else
{
// attribute with path expression
/**
* MBAIRD
* potentially people are referring to objects, not to the object's primary key,
* and then we need to take the primary key attribute of the referenced object
* to help them out.
*/
ClassDescriptor cld = aTableAlias.cld.getRepository().getDescriptorFor(anOrd.getItemClass());
if (cld != null)
{
fld = aTableAlias.cld.getFieldDescriptorByName(cld.getPkFields()[0].getPersistentField().getName());
}
}
return fld;
} | java | private FieldDescriptor getFldFromReference(TableAlias aTableAlias, ObjectReferenceDescriptor anOrd)
{
FieldDescriptor fld = null;
if (aTableAlias == getRoot())
{
// no path expression
FieldDescriptor[] fk = anOrd.getForeignKeyFieldDescriptors(aTableAlias.cld);
if (fk.length > 0)
{
fld = fk[0];
}
}
else
{
// attribute with path expression
/**
* MBAIRD
* potentially people are referring to objects, not to the object's primary key,
* and then we need to take the primary key attribute of the referenced object
* to help them out.
*/
ClassDescriptor cld = aTableAlias.cld.getRepository().getDescriptorFor(anOrd.getItemClass());
if (cld != null)
{
fld = aTableAlias.cld.getFieldDescriptorByName(cld.getPkFields()[0].getPersistentField().getName());
}
}
return fld;
} | [
"private",
"FieldDescriptor",
"getFldFromReference",
"(",
"TableAlias",
"aTableAlias",
",",
"ObjectReferenceDescriptor",
"anOrd",
")",
"{",
"FieldDescriptor",
"fld",
"=",
"null",
";",
"if",
"(",
"aTableAlias",
"==",
"getRoot",
"(",
")",
")",
"{",
"// no path expression\r",
"FieldDescriptor",
"[",
"]",
"fk",
"=",
"anOrd",
".",
"getForeignKeyFieldDescriptors",
"(",
"aTableAlias",
".",
"cld",
")",
";",
"if",
"(",
"fk",
".",
"length",
">",
"0",
")",
"{",
"fld",
"=",
"fk",
"[",
"0",
"]",
";",
"}",
"}",
"else",
"{",
"// attribute with path expression\r",
"/**\r\n * MBAIRD\r\n * potentially people are referring to objects, not to the object's primary key, \r\n * and then we need to take the primary key attribute of the referenced object \r\n * to help them out.\r\n */",
"ClassDescriptor",
"cld",
"=",
"aTableAlias",
".",
"cld",
".",
"getRepository",
"(",
")",
".",
"getDescriptorFor",
"(",
"anOrd",
".",
"getItemClass",
"(",
")",
")",
";",
"if",
"(",
"cld",
"!=",
"null",
")",
"{",
"fld",
"=",
"aTableAlias",
".",
"cld",
".",
"getFieldDescriptorByName",
"(",
"cld",
".",
"getPkFields",
"(",
")",
"[",
"0",
"]",
".",
"getPersistentField",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"fld",
";",
"}"
] | Get FieldDescriptor from Reference | [
"Get",
"FieldDescriptor",
"from",
"Reference"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L400-L430 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.ensureColumns | protected void ensureColumns(List columns, List existingColumns)
{
if (columns == null || columns.isEmpty())
{
return;
}
Iterator iter = columns.iterator();
while (iter.hasNext())
{
FieldHelper cf = (FieldHelper) iter.next();
if (!existingColumns.contains(cf.name))
{
getAttributeInfo(cf.name, false, null, getQuery().getPathClasses());
}
}
} | java | protected void ensureColumns(List columns, List existingColumns)
{
if (columns == null || columns.isEmpty())
{
return;
}
Iterator iter = columns.iterator();
while (iter.hasNext())
{
FieldHelper cf = (FieldHelper) iter.next();
if (!existingColumns.contains(cf.name))
{
getAttributeInfo(cf.name, false, null, getQuery().getPathClasses());
}
}
} | [
"protected",
"void",
"ensureColumns",
"(",
"List",
"columns",
",",
"List",
"existingColumns",
")",
"{",
"if",
"(",
"columns",
"==",
"null",
"||",
"columns",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"Iterator",
"iter",
"=",
"columns",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"FieldHelper",
"cf",
"=",
"(",
"FieldHelper",
")",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"existingColumns",
".",
"contains",
"(",
"cf",
".",
"name",
")",
")",
"{",
"getAttributeInfo",
"(",
"cf",
".",
"name",
",",
"false",
",",
"null",
",",
"getQuery",
"(",
")",
".",
"getPathClasses",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Builds the Join for columns if they are not found among the existingColumns.
@param columns the list of columns represented by Criteria.Field to ensure
@param existingColumns the list of column names (String) that are already appended | [
"Builds",
"the",
"Join",
"for",
"columns",
"if",
"they",
"are",
"not",
"found",
"among",
"the",
"existingColumns",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L480-L497 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendWhereClause | protected void appendWhereClause(StringBuffer where, Criteria crit, StringBuffer stmt)
{
if (where.length() == 0)
{
where = null;
}
if (where != null || (crit != null && !crit.isEmpty()))
{
stmt.append(" WHERE ");
appendClause(where, crit, stmt);
}
} | java | protected void appendWhereClause(StringBuffer where, Criteria crit, StringBuffer stmt)
{
if (where.length() == 0)
{
where = null;
}
if (where != null || (crit != null && !crit.isEmpty()))
{
stmt.append(" WHERE ");
appendClause(where, crit, stmt);
}
} | [
"protected",
"void",
"appendWhereClause",
"(",
"StringBuffer",
"where",
",",
"Criteria",
"crit",
",",
"StringBuffer",
"stmt",
")",
"{",
"if",
"(",
"where",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"where",
"=",
"null",
";",
"}",
"if",
"(",
"where",
"!=",
"null",
"||",
"(",
"crit",
"!=",
"null",
"&&",
"!",
"crit",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"stmt",
".",
"append",
"(",
"\" WHERE \"",
")",
";",
"appendClause",
"(",
"where",
",",
"crit",
",",
"stmt",
")",
";",
"}",
"}"
] | appends a WHERE-clause to the Statement
@param where
@param crit
@param stmt | [
"appends",
"a",
"WHERE",
"-",
"clause",
"to",
"the",
"Statement"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L541-L553 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendHavingClause | protected void appendHavingClause(StringBuffer having, Criteria crit, StringBuffer stmt)
{
if (having.length() == 0)
{
having = null;
}
if (having != null || crit != null)
{
stmt.append(" HAVING ");
appendClause(having, crit, stmt);
}
} | java | protected void appendHavingClause(StringBuffer having, Criteria crit, StringBuffer stmt)
{
if (having.length() == 0)
{
having = null;
}
if (having != null || crit != null)
{
stmt.append(" HAVING ");
appendClause(having, crit, stmt);
}
} | [
"protected",
"void",
"appendHavingClause",
"(",
"StringBuffer",
"having",
",",
"Criteria",
"crit",
",",
"StringBuffer",
"stmt",
")",
"{",
"if",
"(",
"having",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"having",
"=",
"null",
";",
"}",
"if",
"(",
"having",
"!=",
"null",
"||",
"crit",
"!=",
"null",
")",
"{",
"stmt",
".",
"append",
"(",
"\" HAVING \"",
")",
";",
"appendClause",
"(",
"having",
",",
"crit",
",",
"stmt",
")",
";",
"}",
"}"
] | appends a HAVING-clause to the Statement
@param having
@param crit
@param stmt | [
"appends",
"a",
"HAVING",
"-",
"clause",
"to",
"the",
"Statement"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L561-L573 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendBetweenCriteria | private void appendBetweenCriteria(TableAlias alias, PathInfo pathInfo, BetweenCriteria c, StringBuffer buf)
{
appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
buf.append(" AND ");
appendParameter(c.getValue2(), buf);
} | java | private void appendBetweenCriteria(TableAlias alias, PathInfo pathInfo, BetweenCriteria c, StringBuffer buf)
{
appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
buf.append(" AND ");
appendParameter(c.getValue2(), buf);
} | [
"private",
"void",
"appendBetweenCriteria",
"(",
"TableAlias",
"alias",
",",
"PathInfo",
"pathInfo",
",",
"BetweenCriteria",
"c",
",",
"StringBuffer",
"buf",
")",
"{",
"appendColName",
"(",
"alias",
",",
"pathInfo",
",",
"c",
".",
"isTranslateAttribute",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"c",
".",
"getClause",
"(",
")",
")",
";",
"appendParameter",
"(",
"c",
".",
"getValue",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"\" AND \"",
")",
";",
"appendParameter",
"(",
"c",
".",
"getValue2",
"(",
")",
",",
"buf",
")",
";",
"}"
] | Answer the SQL-Clause for a BetweenCriteria
@param alias
@param pathInfo
@param c BetweenCriteria
@param buf | [
"Answer",
"the",
"SQL",
"-",
"Clause",
"for",
"a",
"BetweenCriteria"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L698-L705 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getIndirectionTableColName | private String getIndirectionTableColName(TableAlias mnAlias, String path)
{
int dotIdx = path.lastIndexOf(".");
String column = path.substring(dotIdx);
return mnAlias.alias + column;
} | java | private String getIndirectionTableColName(TableAlias mnAlias, String path)
{
int dotIdx = path.lastIndexOf(".");
String column = path.substring(dotIdx);
return mnAlias.alias + column;
} | [
"private",
"String",
"getIndirectionTableColName",
"(",
"TableAlias",
"mnAlias",
",",
"String",
"path",
")",
"{",
"int",
"dotIdx",
"=",
"path",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"String",
"column",
"=",
"path",
".",
"substring",
"(",
"dotIdx",
")",
";",
"return",
"mnAlias",
".",
"alias",
"+",
"column",
";",
"}"
] | Get the column name from the indirection table.
@param mnAlias
@param path | [
"Get",
"the",
"column",
"name",
"from",
"the",
"indirection",
"table",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L748-L753 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendLikeCriteria | private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c, StringBuffer buf)
{
appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
buf.append(m_platform.getEscapeClause(c));
} | java | private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c, StringBuffer buf)
{
appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
buf.append(m_platform.getEscapeClause(c));
} | [
"private",
"void",
"appendLikeCriteria",
"(",
"TableAlias",
"alias",
",",
"PathInfo",
"pathInfo",
",",
"LikeCriteria",
"c",
",",
"StringBuffer",
"buf",
")",
"{",
"appendColName",
"(",
"alias",
",",
"pathInfo",
",",
"c",
".",
"isTranslateAttribute",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"c",
".",
"getClause",
"(",
")",
")",
";",
"appendParameter",
"(",
"c",
".",
"getValue",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"m_platform",
".",
"getEscapeClause",
"(",
"c",
")",
")",
";",
"}"
] | Answer the SQL-Clause for a LikeCriteria
@param c
@param buf | [
"Answer",
"the",
"SQL",
"-",
"Clause",
"for",
"a",
"LikeCriteria"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L833-L840 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendSQLClause | protected void appendSQLClause(SelectionCriteria c, StringBuffer buf)
{
// BRJ : handle SqlCriteria
if (c instanceof SqlCriteria)
{
buf.append(c.getAttribute());
return;
}
// BRJ : criteria attribute is a query
if (c.getAttribute() instanceof Query)
{
Query q = (Query) c.getAttribute();
buf.append("(");
buf.append(getSubQuerySQL(q));
buf.append(")");
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
return;
}
AttributeInfo attrInfo = getAttributeInfo((String) c.getAttribute(), false, c.getUserAlias(), c.getPathClasses());
TableAlias alias = attrInfo.tableAlias;
if (alias != null)
{
boolean hasExtents = alias.hasExtents();
if (hasExtents)
{
// BRJ : surround with braces if alias has extents
buf.append("(");
appendCriteria(alias, attrInfo.pathInfo, c, buf);
c.setNumberOfExtentsToBind(alias.extents.size());
Iterator iter = alias.iterateExtents();
while (iter.hasNext())
{
TableAlias tableAlias = (TableAlias) iter.next();
buf.append(" OR ");
appendCriteria(tableAlias, attrInfo.pathInfo, c, buf);
}
buf.append(")");
}
else
{
// no extents
appendCriteria(alias, attrInfo.pathInfo, c, buf);
}
}
else
{
// alias null
appendCriteria(alias, attrInfo.pathInfo, c, buf);
}
} | java | protected void appendSQLClause(SelectionCriteria c, StringBuffer buf)
{
// BRJ : handle SqlCriteria
if (c instanceof SqlCriteria)
{
buf.append(c.getAttribute());
return;
}
// BRJ : criteria attribute is a query
if (c.getAttribute() instanceof Query)
{
Query q = (Query) c.getAttribute();
buf.append("(");
buf.append(getSubQuerySQL(q));
buf.append(")");
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
return;
}
AttributeInfo attrInfo = getAttributeInfo((String) c.getAttribute(), false, c.getUserAlias(), c.getPathClasses());
TableAlias alias = attrInfo.tableAlias;
if (alias != null)
{
boolean hasExtents = alias.hasExtents();
if (hasExtents)
{
// BRJ : surround with braces if alias has extents
buf.append("(");
appendCriteria(alias, attrInfo.pathInfo, c, buf);
c.setNumberOfExtentsToBind(alias.extents.size());
Iterator iter = alias.iterateExtents();
while (iter.hasNext())
{
TableAlias tableAlias = (TableAlias) iter.next();
buf.append(" OR ");
appendCriteria(tableAlias, attrInfo.pathInfo, c, buf);
}
buf.append(")");
}
else
{
// no extents
appendCriteria(alias, attrInfo.pathInfo, c, buf);
}
}
else
{
// alias null
appendCriteria(alias, attrInfo.pathInfo, c, buf);
}
} | [
"protected",
"void",
"appendSQLClause",
"(",
"SelectionCriteria",
"c",
",",
"StringBuffer",
"buf",
")",
"{",
"// BRJ : handle SqlCriteria\r",
"if",
"(",
"c",
"instanceof",
"SqlCriteria",
")",
"{",
"buf",
".",
"append",
"(",
"c",
".",
"getAttribute",
"(",
")",
")",
";",
"return",
";",
"}",
"// BRJ : criteria attribute is a query\r",
"if",
"(",
"c",
".",
"getAttribute",
"(",
")",
"instanceof",
"Query",
")",
"{",
"Query",
"q",
"=",
"(",
"Query",
")",
"c",
".",
"getAttribute",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\"(\"",
")",
";",
"buf",
".",
"append",
"(",
"getSubQuerySQL",
"(",
"q",
")",
")",
";",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"buf",
".",
"append",
"(",
"c",
".",
"getClause",
"(",
")",
")",
";",
"appendParameter",
"(",
"c",
".",
"getValue",
"(",
")",
",",
"buf",
")",
";",
"return",
";",
"}",
"AttributeInfo",
"attrInfo",
"=",
"getAttributeInfo",
"(",
"(",
"String",
")",
"c",
".",
"getAttribute",
"(",
")",
",",
"false",
",",
"c",
".",
"getUserAlias",
"(",
")",
",",
"c",
".",
"getPathClasses",
"(",
")",
")",
";",
"TableAlias",
"alias",
"=",
"attrInfo",
".",
"tableAlias",
";",
"if",
"(",
"alias",
"!=",
"null",
")",
"{",
"boolean",
"hasExtents",
"=",
"alias",
".",
"hasExtents",
"(",
")",
";",
"if",
"(",
"hasExtents",
")",
"{",
"// BRJ : surround with braces if alias has extents\r",
"buf",
".",
"append",
"(",
"\"(\"",
")",
";",
"appendCriteria",
"(",
"alias",
",",
"attrInfo",
".",
"pathInfo",
",",
"c",
",",
"buf",
")",
";",
"c",
".",
"setNumberOfExtentsToBind",
"(",
"alias",
".",
"extents",
".",
"size",
"(",
")",
")",
";",
"Iterator",
"iter",
"=",
"alias",
".",
"iterateExtents",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"TableAlias",
"tableAlias",
"=",
"(",
"TableAlias",
")",
"iter",
".",
"next",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\" OR \"",
")",
";",
"appendCriteria",
"(",
"tableAlias",
",",
"attrInfo",
".",
"pathInfo",
",",
"c",
",",
"buf",
")",
";",
"}",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"else",
"{",
"// no extents\r",
"appendCriteria",
"(",
"alias",
",",
"attrInfo",
".",
"pathInfo",
",",
"c",
",",
"buf",
")",
";",
"}",
"}",
"else",
"{",
"// alias null\r",
"appendCriteria",
"(",
"alias",
",",
"attrInfo",
".",
"pathInfo",
",",
"c",
",",
"buf",
")",
";",
"}",
"}"
] | Answer the SQL-Clause for a SelectionCriteria
If the Criteria references a class with extents an OR-Clause is
added for each extent
@param c SelectionCriteria | [
"Answer",
"the",
"SQL",
"-",
"Clause",
"for",
"a",
"SelectionCriteria",
"If",
"the",
"Criteria",
"references",
"a",
"class",
"with",
"extents",
"an",
"OR",
"-",
"Clause",
"is",
"added",
"for",
"each",
"extent"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L892-L948 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendParameter | private void appendParameter(Object value, StringBuffer buf)
{
if (value instanceof Query)
{
appendSubQuery((Query) value, buf);
}
else
{
buf.append("?");
}
} | java | private void appendParameter(Object value, StringBuffer buf)
{
if (value instanceof Query)
{
appendSubQuery((Query) value, buf);
}
else
{
buf.append("?");
}
} | [
"private",
"void",
"appendParameter",
"(",
"Object",
"value",
",",
"StringBuffer",
"buf",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Query",
")",
"{",
"appendSubQuery",
"(",
"(",
"Query",
")",
"value",
",",
"buf",
")",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"\"?\"",
")",
";",
"}",
"}"
] | Append the Parameter
Add the place holder ? or the SubQuery
@param value the value of the criteria | [
"Append",
"the",
"Parameter",
"Add",
"the",
"place",
"holder",
"?",
"or",
"the",
"SubQuery"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L955-L965 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendSubQuery | private void appendSubQuery(Query subQuery, StringBuffer buf)
{
buf.append(" (");
buf.append(getSubQuerySQL(subQuery));
buf.append(") ");
} | java | private void appendSubQuery(Query subQuery, StringBuffer buf)
{
buf.append(" (");
buf.append(getSubQuerySQL(subQuery));
buf.append(") ");
} | [
"private",
"void",
"appendSubQuery",
"(",
"Query",
"subQuery",
",",
"StringBuffer",
"buf",
")",
"{",
"buf",
".",
"append",
"(",
"\" (\"",
")",
";",
"buf",
".",
"append",
"(",
"getSubQuerySQL",
"(",
"subQuery",
")",
")",
";",
"buf",
".",
"append",
"(",
"\") \"",
")",
";",
"}"
] | Append a SubQuery the SQL-Clause
@param subQuery the subQuery value of SelectionCriteria | [
"Append",
"a",
"SubQuery",
"the",
"SQL",
"-",
"Clause"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L971-L976 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getSubQuerySQL | private String getSubQuerySQL(Query subQuery)
{
ClassDescriptor cld = getRoot().cld.getRepository().getDescriptorFor(subQuery.getSearchClass());
String sql;
if (subQuery instanceof QueryBySQL)
{
sql = ((QueryBySQL) subQuery).getSql();
}
else
{
sql = new SqlSelectStatement(this, m_platform, cld, subQuery, m_logger).getStatement();
}
return sql;
} | java | private String getSubQuerySQL(Query subQuery)
{
ClassDescriptor cld = getRoot().cld.getRepository().getDescriptorFor(subQuery.getSearchClass());
String sql;
if (subQuery instanceof QueryBySQL)
{
sql = ((QueryBySQL) subQuery).getSql();
}
else
{
sql = new SqlSelectStatement(this, m_platform, cld, subQuery, m_logger).getStatement();
}
return sql;
} | [
"private",
"String",
"getSubQuerySQL",
"(",
"Query",
"subQuery",
")",
"{",
"ClassDescriptor",
"cld",
"=",
"getRoot",
"(",
")",
".",
"cld",
".",
"getRepository",
"(",
")",
".",
"getDescriptorFor",
"(",
"subQuery",
".",
"getSearchClass",
"(",
")",
")",
";",
"String",
"sql",
";",
"if",
"(",
"subQuery",
"instanceof",
"QueryBySQL",
")",
"{",
"sql",
"=",
"(",
"(",
"QueryBySQL",
")",
"subQuery",
")",
".",
"getSql",
"(",
")",
";",
"}",
"else",
"{",
"sql",
"=",
"new",
"SqlSelectStatement",
"(",
"this",
",",
"m_platform",
",",
"cld",
",",
"subQuery",
",",
"m_logger",
")",
".",
"getStatement",
"(",
")",
";",
"}",
"return",
"sql",
";",
"}"
] | Convert subQuery to SQL
@param subQuery the subQuery value of SelectionCriteria | [
"Convert",
"subQuery",
"to",
"SQL"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L982-L997 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.addJoin | private void addJoin(TableAlias left, Object[] leftKeys, TableAlias right, Object[] rightKeys, boolean outer,
String name)
{
TableAlias extAlias, rightCopy;
left.addJoin(new Join(left, leftKeys, right, rightKeys, outer, name));
// build join between left and extents of right
if (right.hasExtents())
{
for (int i = 0; i < right.extents.size(); i++)
{
extAlias = (TableAlias) right.extents.get(i);
FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[]) rightKeys);
left.addJoin(new Join(left, leftKeys, extAlias, extKeys, true, name));
}
}
// we need to copy the alias on the right for each extent on the left
if (left.hasExtents())
{
for (int i = 0; i < left.extents.size(); i++)
{
extAlias = (TableAlias) left.extents.get(i);
FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[]) leftKeys);
rightCopy = right.copy("C" + i);
// copies are treated like normal extents
right.extents.add(rightCopy);
right.extents.addAll(rightCopy.extents);
addJoin(extAlias, extKeys, rightCopy, rightKeys, true, name);
}
}
} | java | private void addJoin(TableAlias left, Object[] leftKeys, TableAlias right, Object[] rightKeys, boolean outer,
String name)
{
TableAlias extAlias, rightCopy;
left.addJoin(new Join(left, leftKeys, right, rightKeys, outer, name));
// build join between left and extents of right
if (right.hasExtents())
{
for (int i = 0; i < right.extents.size(); i++)
{
extAlias = (TableAlias) right.extents.get(i);
FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[]) rightKeys);
left.addJoin(new Join(left, leftKeys, extAlias, extKeys, true, name));
}
}
// we need to copy the alias on the right for each extent on the left
if (left.hasExtents())
{
for (int i = 0; i < left.extents.size(); i++)
{
extAlias = (TableAlias) left.extents.get(i);
FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[]) leftKeys);
rightCopy = right.copy("C" + i);
// copies are treated like normal extents
right.extents.add(rightCopy);
right.extents.addAll(rightCopy.extents);
addJoin(extAlias, extKeys, rightCopy, rightKeys, true, name);
}
}
} | [
"private",
"void",
"addJoin",
"(",
"TableAlias",
"left",
",",
"Object",
"[",
"]",
"leftKeys",
",",
"TableAlias",
"right",
",",
"Object",
"[",
"]",
"rightKeys",
",",
"boolean",
"outer",
",",
"String",
"name",
")",
"{",
"TableAlias",
"extAlias",
",",
"rightCopy",
";",
"left",
".",
"addJoin",
"(",
"new",
"Join",
"(",
"left",
",",
"leftKeys",
",",
"right",
",",
"rightKeys",
",",
"outer",
",",
"name",
")",
")",
";",
"// build join between left and extents of right\r",
"if",
"(",
"right",
".",
"hasExtents",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"right",
".",
"extents",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"extAlias",
"=",
"(",
"TableAlias",
")",
"right",
".",
"extents",
".",
"get",
"(",
"i",
")",
";",
"FieldDescriptor",
"[",
"]",
"extKeys",
"=",
"getExtentFieldDescriptors",
"(",
"extAlias",
",",
"(",
"FieldDescriptor",
"[",
"]",
")",
"rightKeys",
")",
";",
"left",
".",
"addJoin",
"(",
"new",
"Join",
"(",
"left",
",",
"leftKeys",
",",
"extAlias",
",",
"extKeys",
",",
"true",
",",
"name",
")",
")",
";",
"}",
"}",
"// we need to copy the alias on the right for each extent on the left\r",
"if",
"(",
"left",
".",
"hasExtents",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"left",
".",
"extents",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"extAlias",
"=",
"(",
"TableAlias",
")",
"left",
".",
"extents",
".",
"get",
"(",
"i",
")",
";",
"FieldDescriptor",
"[",
"]",
"extKeys",
"=",
"getExtentFieldDescriptors",
"(",
"extAlias",
",",
"(",
"FieldDescriptor",
"[",
"]",
")",
"leftKeys",
")",
";",
"rightCopy",
"=",
"right",
".",
"copy",
"(",
"\"C\"",
"+",
"i",
")",
";",
"// copies are treated like normal extents\r",
"right",
".",
"extents",
".",
"add",
"(",
"rightCopy",
")",
";",
"right",
".",
"extents",
".",
"addAll",
"(",
"rightCopy",
".",
"extents",
")",
";",
"addJoin",
"(",
"extAlias",
",",
"extKeys",
",",
"rightCopy",
",",
"rightKeys",
",",
"true",
",",
"name",
")",
";",
"}",
"}",
"}"
] | add a join between two aliases
TODO BRJ : This needs refactoring, it looks kind of weird
no extents
A1 -> A2
extents on the right
A1 -> A2
A1 -> A2E0
extents on the left : copy alias on right, extents point to copies
A1 -> A2
A1E0 -> A2C0
extents on the left and right
A1 -> A2
A1 -> A2E0
A1E0 -> A2C0
A1E0 -> A2E0C0
@param left
@param leftKeys
@param right
@param rightKeys
@param outer
@param name | [
"add",
"a",
"join",
"between",
"two",
"aliases"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1204-L1239 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getExtentFieldDescriptors | private FieldDescriptor[] getExtentFieldDescriptors(TableAlias extAlias, FieldDescriptor[] fds)
{
FieldDescriptor[] result = new FieldDescriptor[fds.length];
for (int i = 0; i < fds.length; i++)
{
result[i] = extAlias.cld.getFieldDescriptorByName(fds[i].getAttributeName());
}
return result;
} | java | private FieldDescriptor[] getExtentFieldDescriptors(TableAlias extAlias, FieldDescriptor[] fds)
{
FieldDescriptor[] result = new FieldDescriptor[fds.length];
for (int i = 0; i < fds.length; i++)
{
result[i] = extAlias.cld.getFieldDescriptorByName(fds[i].getAttributeName());
}
return result;
} | [
"private",
"FieldDescriptor",
"[",
"]",
"getExtentFieldDescriptors",
"(",
"TableAlias",
"extAlias",
",",
"FieldDescriptor",
"[",
"]",
"fds",
")",
"{",
"FieldDescriptor",
"[",
"]",
"result",
"=",
"new",
"FieldDescriptor",
"[",
"fds",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fds",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"extAlias",
".",
"cld",
".",
"getFieldDescriptorByName",
"(",
"fds",
"[",
"i",
"]",
".",
"getAttributeName",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Get the FieldDescriptors of the extent based on the FieldDescriptors of the parent. | [
"Get",
"the",
"FieldDescriptors",
"of",
"the",
"extent",
"based",
"on",
"the",
"FieldDescriptors",
"of",
"the",
"parent",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1244-L1254 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.createTableAlias | private TableAlias createTableAlias(String aTable, String aPath, String aUserAlias)
{
if (aUserAlias == null)
{
return createTableAlias(aTable, aPath);
}
else
{
return createTableAlias(aTable, aUserAlias + ALIAS_SEPARATOR + aPath);
}
} | java | private TableAlias createTableAlias(String aTable, String aPath, String aUserAlias)
{
if (aUserAlias == null)
{
return createTableAlias(aTable, aPath);
}
else
{
return createTableAlias(aTable, aUserAlias + ALIAS_SEPARATOR + aPath);
}
} | [
"private",
"TableAlias",
"createTableAlias",
"(",
"String",
"aTable",
",",
"String",
"aPath",
",",
"String",
"aUserAlias",
")",
"{",
"if",
"(",
"aUserAlias",
"==",
"null",
")",
"{",
"return",
"createTableAlias",
"(",
"aTable",
",",
"aPath",
")",
";",
"}",
"else",
"{",
"return",
"createTableAlias",
"(",
"aTable",
",",
"aUserAlias",
"+",
"ALIAS_SEPARATOR",
"+",
"aPath",
")",
";",
"}",
"}"
] | Create a TableAlias for path or userAlias
@param aTable
@param aPath
@param aUserAlias
@return TableAlias | [
"Create",
"a",
"TableAlias",
"for",
"path",
"or",
"userAlias"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1319-L1329 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getTableAliasForPath | private TableAlias getTableAliasForPath(String aPath, List hintClasses)
{
return (TableAlias) m_pathToAlias.get(buildAliasKey(aPath, hintClasses));
} | java | private TableAlias getTableAliasForPath(String aPath, List hintClasses)
{
return (TableAlias) m_pathToAlias.get(buildAliasKey(aPath, hintClasses));
} | [
"private",
"TableAlias",
"getTableAliasForPath",
"(",
"String",
"aPath",
",",
"List",
"hintClasses",
")",
"{",
"return",
"(",
"TableAlias",
")",
"m_pathToAlias",
".",
"get",
"(",
"buildAliasKey",
"(",
"aPath",
",",
"hintClasses",
")",
")",
";",
"}"
] | Answer the TableAlias for aPath
@param aPath
@param hintClasses
@return TableAlias, null if none | [
"Answer",
"the",
"TableAlias",
"for",
"aPath"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1359-L1362 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.setTableAliasForPath | private void setTableAliasForPath(String aPath, List hintClasses, TableAlias anAlias)
{
m_pathToAlias.put(buildAliasKey(aPath, hintClasses), anAlias);
} | java | private void setTableAliasForPath(String aPath, List hintClasses, TableAlias anAlias)
{
m_pathToAlias.put(buildAliasKey(aPath, hintClasses), anAlias);
} | [
"private",
"void",
"setTableAliasForPath",
"(",
"String",
"aPath",
",",
"List",
"hintClasses",
",",
"TableAlias",
"anAlias",
")",
"{",
"m_pathToAlias",
".",
"put",
"(",
"buildAliasKey",
"(",
"aPath",
",",
"hintClasses",
")",
",",
"anAlias",
")",
";",
"}"
] | Set the TableAlias for aPath
@param aPath
@param hintClasses
@param TableAlias | [
"Set",
"the",
"TableAlias",
"for",
"aPath"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1370-L1373 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.buildAliasKey | private String buildAliasKey(String aPath, List hintClasses)
{
if (hintClasses == null || hintClasses.isEmpty())
{
return aPath;
}
StringBuffer buf = new StringBuffer(aPath);
for (Iterator iter = hintClasses.iterator(); iter.hasNext();)
{
Class hint = (Class) iter.next();
buf.append(" ");
buf.append(hint.getName());
}
return buf.toString();
} | java | private String buildAliasKey(String aPath, List hintClasses)
{
if (hintClasses == null || hintClasses.isEmpty())
{
return aPath;
}
StringBuffer buf = new StringBuffer(aPath);
for (Iterator iter = hintClasses.iterator(); iter.hasNext();)
{
Class hint = (Class) iter.next();
buf.append(" ");
buf.append(hint.getName());
}
return buf.toString();
} | [
"private",
"String",
"buildAliasKey",
"(",
"String",
"aPath",
",",
"List",
"hintClasses",
")",
"{",
"if",
"(",
"hintClasses",
"==",
"null",
"||",
"hintClasses",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"aPath",
";",
"}",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"aPath",
")",
";",
"for",
"(",
"Iterator",
"iter",
"=",
"hintClasses",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Class",
"hint",
"=",
"(",
"Class",
")",
"iter",
".",
"next",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\" \"",
")",
";",
"buf",
".",
"append",
"(",
"hint",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Build the key for the TableAlias based on the path and the hints
@param aPath
@param hintClasses
@return the key for the TableAlias | [
"Build",
"the",
"key",
"for",
"the",
"TableAlias",
"based",
"on",
"the",
"path",
"and",
"the",
"hints"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1381-L1396 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.setTableAliasForClassDescriptor | private void setTableAliasForClassDescriptor(ClassDescriptor aCld, TableAlias anAlias)
{
if (m_cldToAlias.get(aCld) == null)
{
m_cldToAlias.put(aCld, anAlias);
}
} | java | private void setTableAliasForClassDescriptor(ClassDescriptor aCld, TableAlias anAlias)
{
if (m_cldToAlias.get(aCld) == null)
{
m_cldToAlias.put(aCld, anAlias);
}
} | [
"private",
"void",
"setTableAliasForClassDescriptor",
"(",
"ClassDescriptor",
"aCld",
",",
"TableAlias",
"anAlias",
")",
"{",
"if",
"(",
"m_cldToAlias",
".",
"get",
"(",
"aCld",
")",
"==",
"null",
")",
"{",
"m_cldToAlias",
".",
"put",
"(",
"aCld",
",",
"anAlias",
")",
";",
"}",
"}"
] | Set the TableAlias for ClassDescriptor | [
"Set",
"the",
"TableAlias",
"for",
"ClassDescriptor"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1409-L1415 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getTableAliasForPath | private TableAlias getTableAliasForPath(String aPath, String aUserAlias, List hintClasses)
{
if (aUserAlias == null)
{
return getTableAliasForPath(aPath, hintClasses);
}
else
{
return getTableAliasForPath(aUserAlias + ALIAS_SEPARATOR + aPath, hintClasses);
}
} | java | private TableAlias getTableAliasForPath(String aPath, String aUserAlias, List hintClasses)
{
if (aUserAlias == null)
{
return getTableAliasForPath(aPath, hintClasses);
}
else
{
return getTableAliasForPath(aUserAlias + ALIAS_SEPARATOR + aPath, hintClasses);
}
} | [
"private",
"TableAlias",
"getTableAliasForPath",
"(",
"String",
"aPath",
",",
"String",
"aUserAlias",
",",
"List",
"hintClasses",
")",
"{",
"if",
"(",
"aUserAlias",
"==",
"null",
")",
"{",
"return",
"getTableAliasForPath",
"(",
"aPath",
",",
"hintClasses",
")",
";",
"}",
"else",
"{",
"return",
"getTableAliasForPath",
"(",
"aUserAlias",
"+",
"ALIAS_SEPARATOR",
"+",
"aPath",
",",
"hintClasses",
")",
";",
"}",
"}"
] | Answer the TableAlias for aPath or aUserAlias
@param aPath
@param aUserAlias
@param hintClasses
@return TableAlias, null if none | [
"Answer",
"the",
"TableAlias",
"for",
"aPath",
"or",
"aUserAlias"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1424-L1434 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendGroupByClause | protected void appendGroupByClause(List groupByFields, StringBuffer buf)
{
if (groupByFields == null || groupByFields.size() == 0)
{
return;
}
buf.append(" GROUP BY ");
for (int i = 0; i < groupByFields.size(); i++)
{
FieldHelper cf = (FieldHelper) groupByFields.get(i);
if (i > 0)
{
buf.append(",");
}
appendColName(cf.name, false, null, buf);
}
} | java | protected void appendGroupByClause(List groupByFields, StringBuffer buf)
{
if (groupByFields == null || groupByFields.size() == 0)
{
return;
}
buf.append(" GROUP BY ");
for (int i = 0; i < groupByFields.size(); i++)
{
FieldHelper cf = (FieldHelper) groupByFields.get(i);
if (i > 0)
{
buf.append(",");
}
appendColName(cf.name, false, null, buf);
}
} | [
"protected",
"void",
"appendGroupByClause",
"(",
"List",
"groupByFields",
",",
"StringBuffer",
"buf",
")",
"{",
"if",
"(",
"groupByFields",
"==",
"null",
"||",
"groupByFields",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"buf",
".",
"append",
"(",
"\" GROUP BY \"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"groupByFields",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"FieldHelper",
"cf",
"=",
"(",
"FieldHelper",
")",
"groupByFields",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"i",
">",
"0",
")",
"{",
"buf",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"appendColName",
"(",
"cf",
".",
"name",
",",
"false",
",",
"null",
",",
"buf",
")",
";",
"}",
"}"
] | Appends the GROUP BY clause for the Query
@param groupByFields
@param buf | [
"Appends",
"the",
"GROUP",
"BY",
"clause",
"for",
"the",
"Query"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1520-L1539 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendTableWithJoins | protected void appendTableWithJoins(TableAlias alias, StringBuffer where, StringBuffer buf)
{
int stmtFromPos = 0;
byte joinSyntax = getJoinSyntaxType();
if (joinSyntax == SQL92_JOIN_SYNTAX)
{
stmtFromPos = buf.length(); // store position of join (by: Terry Dexter)
}
if (alias == getRoot())
{
// BRJ: also add indirection table to FROM-clause for MtoNQuery
if (getQuery() instanceof MtoNQuery)
{
MtoNQuery mnQuery = (MtoNQuery)m_query;
buf.append(getTableAliasForPath(mnQuery.getIndirectionTable(), null).getTableAndAlias());
buf.append(", ");
}
buf.append(alias.getTableAndAlias());
}
else if (joinSyntax != SQL92_NOPAREN_JOIN_SYNTAX)
{
buf.append(alias.getTableAndAlias());
}
if (!alias.hasJoins())
{
return;
}
for (Iterator it = alias.iterateJoins(); it.hasNext();)
{
Join join = (Join) it.next();
if (joinSyntax == SQL92_JOIN_SYNTAX)
{
appendJoinSQL92(join, where, buf);
if (it.hasNext())
{
buf.insert(stmtFromPos, "(");
buf.append(")");
}
}
else if (joinSyntax == SQL92_NOPAREN_JOIN_SYNTAX)
{
appendJoinSQL92NoParen(join, where, buf);
}
else
{
appendJoin(where, buf, join);
}
}
} | java | protected void appendTableWithJoins(TableAlias alias, StringBuffer where, StringBuffer buf)
{
int stmtFromPos = 0;
byte joinSyntax = getJoinSyntaxType();
if (joinSyntax == SQL92_JOIN_SYNTAX)
{
stmtFromPos = buf.length(); // store position of join (by: Terry Dexter)
}
if (alias == getRoot())
{
// BRJ: also add indirection table to FROM-clause for MtoNQuery
if (getQuery() instanceof MtoNQuery)
{
MtoNQuery mnQuery = (MtoNQuery)m_query;
buf.append(getTableAliasForPath(mnQuery.getIndirectionTable(), null).getTableAndAlias());
buf.append(", ");
}
buf.append(alias.getTableAndAlias());
}
else if (joinSyntax != SQL92_NOPAREN_JOIN_SYNTAX)
{
buf.append(alias.getTableAndAlias());
}
if (!alias.hasJoins())
{
return;
}
for (Iterator it = alias.iterateJoins(); it.hasNext();)
{
Join join = (Join) it.next();
if (joinSyntax == SQL92_JOIN_SYNTAX)
{
appendJoinSQL92(join, where, buf);
if (it.hasNext())
{
buf.insert(stmtFromPos, "(");
buf.append(")");
}
}
else if (joinSyntax == SQL92_NOPAREN_JOIN_SYNTAX)
{
appendJoinSQL92NoParen(join, where, buf);
}
else
{
appendJoin(where, buf, join);
}
}
} | [
"protected",
"void",
"appendTableWithJoins",
"(",
"TableAlias",
"alias",
",",
"StringBuffer",
"where",
",",
"StringBuffer",
"buf",
")",
"{",
"int",
"stmtFromPos",
"=",
"0",
";",
"byte",
"joinSyntax",
"=",
"getJoinSyntaxType",
"(",
")",
";",
"if",
"(",
"joinSyntax",
"==",
"SQL92_JOIN_SYNTAX",
")",
"{",
"stmtFromPos",
"=",
"buf",
".",
"length",
"(",
")",
";",
"// store position of join (by: Terry Dexter)\r",
"}",
"if",
"(",
"alias",
"==",
"getRoot",
"(",
")",
")",
"{",
"// BRJ: also add indirection table to FROM-clause for MtoNQuery \r",
"if",
"(",
"getQuery",
"(",
")",
"instanceof",
"MtoNQuery",
")",
"{",
"MtoNQuery",
"mnQuery",
"=",
"(",
"MtoNQuery",
")",
"m_query",
";",
"buf",
".",
"append",
"(",
"getTableAliasForPath",
"(",
"mnQuery",
".",
"getIndirectionTable",
"(",
")",
",",
"null",
")",
".",
"getTableAndAlias",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"buf",
".",
"append",
"(",
"alias",
".",
"getTableAndAlias",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"joinSyntax",
"!=",
"SQL92_NOPAREN_JOIN_SYNTAX",
")",
"{",
"buf",
".",
"append",
"(",
"alias",
".",
"getTableAndAlias",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"alias",
".",
"hasJoins",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"Iterator",
"it",
"=",
"alias",
".",
"iterateJoins",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Join",
"join",
"=",
"(",
"Join",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"joinSyntax",
"==",
"SQL92_JOIN_SYNTAX",
")",
"{",
"appendJoinSQL92",
"(",
"join",
",",
"where",
",",
"buf",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"buf",
".",
"insert",
"(",
"stmtFromPos",
",",
"\"(\"",
")",
";",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"joinSyntax",
"==",
"SQL92_NOPAREN_JOIN_SYNTAX",
")",
"{",
"appendJoinSQL92NoParen",
"(",
"join",
",",
"where",
",",
"buf",
")",
";",
"}",
"else",
"{",
"appendJoin",
"(",
"where",
",",
"buf",
",",
"join",
")",
";",
"}",
"}",
"}"
] | Appends to the statement table and all tables joined to it.
@param alias the table alias
@param where append conditions for WHERE clause here | [
"Appends",
"to",
"the",
"statement",
"table",
"and",
"all",
"tables",
"joined",
"to",
"it",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1546-L1600 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendJoin | private void appendJoin(StringBuffer where, StringBuffer buf, Join join)
{
buf.append(",");
appendTableWithJoins(join.right, where, buf);
if (where.length() > 0)
{
where.append(" AND ");
}
join.appendJoinEqualities(where);
} | java | private void appendJoin(StringBuffer where, StringBuffer buf, Join join)
{
buf.append(",");
appendTableWithJoins(join.right, where, buf);
if (where.length() > 0)
{
where.append(" AND ");
}
join.appendJoinEqualities(where);
} | [
"private",
"void",
"appendJoin",
"(",
"StringBuffer",
"where",
",",
"StringBuffer",
"buf",
",",
"Join",
"join",
")",
"{",
"buf",
".",
"append",
"(",
"\",\"",
")",
";",
"appendTableWithJoins",
"(",
"join",
".",
"right",
",",
"where",
",",
"buf",
")",
";",
"if",
"(",
"where",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"where",
".",
"append",
"(",
"\" AND \"",
")",
";",
"}",
"join",
".",
"appendJoinEqualities",
"(",
"where",
")",
";",
"}"
] | Append Join for non SQL92 Syntax | [
"Append",
"Join",
"for",
"non",
"SQL92",
"Syntax"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1605-L1614 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendJoinSQL92 | private void appendJoinSQL92(Join join, StringBuffer where, StringBuffer buf)
{
if (join.isOuter)
{
buf.append(" LEFT OUTER JOIN ");
}
else
{
buf.append(" INNER JOIN ");
}
if (join.right.hasJoins())
{
buf.append("(");
appendTableWithJoins(join.right, where, buf);
buf.append(")");
}
else
{
appendTableWithJoins(join.right, where, buf);
}
buf.append(" ON ");
join.appendJoinEqualities(buf);
} | java | private void appendJoinSQL92(Join join, StringBuffer where, StringBuffer buf)
{
if (join.isOuter)
{
buf.append(" LEFT OUTER JOIN ");
}
else
{
buf.append(" INNER JOIN ");
}
if (join.right.hasJoins())
{
buf.append("(");
appendTableWithJoins(join.right, where, buf);
buf.append(")");
}
else
{
appendTableWithJoins(join.right, where, buf);
}
buf.append(" ON ");
join.appendJoinEqualities(buf);
} | [
"private",
"void",
"appendJoinSQL92",
"(",
"Join",
"join",
",",
"StringBuffer",
"where",
",",
"StringBuffer",
"buf",
")",
"{",
"if",
"(",
"join",
".",
"isOuter",
")",
"{",
"buf",
".",
"append",
"(",
"\" LEFT OUTER JOIN \"",
")",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"\" INNER JOIN \"",
")",
";",
"}",
"if",
"(",
"join",
".",
"right",
".",
"hasJoins",
"(",
")",
")",
"{",
"buf",
".",
"append",
"(",
"\"(\"",
")",
";",
"appendTableWithJoins",
"(",
"join",
".",
"right",
",",
"where",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"else",
"{",
"appendTableWithJoins",
"(",
"join",
".",
"right",
",",
"where",
",",
"buf",
")",
";",
"}",
"buf",
".",
"append",
"(",
"\" ON \"",
")",
";",
"join",
".",
"appendJoinEqualities",
"(",
"buf",
")",
";",
"}"
] | Append Join for SQL92 Syntax | [
"Append",
"Join",
"for",
"SQL92",
"Syntax"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1619-L1641 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendJoinSQL92NoParen | private void appendJoinSQL92NoParen(Join join, StringBuffer where, StringBuffer buf)
{
if (join.isOuter)
{
buf.append(" LEFT OUTER JOIN ");
}
else
{
buf.append(" INNER JOIN ");
}
buf.append(join.right.getTableAndAlias());
buf.append(" ON ");
join.appendJoinEqualities(buf);
appendTableWithJoins(join.right, where, buf);
} | java | private void appendJoinSQL92NoParen(Join join, StringBuffer where, StringBuffer buf)
{
if (join.isOuter)
{
buf.append(" LEFT OUTER JOIN ");
}
else
{
buf.append(" INNER JOIN ");
}
buf.append(join.right.getTableAndAlias());
buf.append(" ON ");
join.appendJoinEqualities(buf);
appendTableWithJoins(join.right, where, buf);
} | [
"private",
"void",
"appendJoinSQL92NoParen",
"(",
"Join",
"join",
",",
"StringBuffer",
"where",
",",
"StringBuffer",
"buf",
")",
"{",
"if",
"(",
"join",
".",
"isOuter",
")",
"{",
"buf",
".",
"append",
"(",
"\" LEFT OUTER JOIN \"",
")",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"\" INNER JOIN \"",
")",
";",
"}",
"buf",
".",
"append",
"(",
"join",
".",
"right",
".",
"getTableAndAlias",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\" ON \"",
")",
";",
"join",
".",
"appendJoinEqualities",
"(",
"buf",
")",
";",
"appendTableWithJoins",
"(",
"join",
".",
"right",
",",
"where",
",",
"buf",
")",
";",
"}"
] | Append Join for SQL92 Syntax without parentheses | [
"Append",
"Join",
"for",
"SQL92",
"Syntax",
"without",
"parentheses"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1646-L1662 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.buildJoinTree | private void buildJoinTree(Criteria crit)
{
Enumeration e = crit.getElements();
while (e.hasMoreElements())
{
Object o = e.nextElement();
if (o instanceof Criteria)
{
buildJoinTree((Criteria) o);
}
else
{
SelectionCriteria c = (SelectionCriteria) o;
// BRJ skip SqlCriteria
if (c instanceof SqlCriteria)
{
continue;
}
// BRJ: Outer join for OR
boolean useOuterJoin = (crit.getType() == Criteria.OR);
// BRJ: do not build join tree for subQuery attribute
if (c.getAttribute() != null && c.getAttribute() instanceof String)
{
//buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getAlias(), c.getPathClasses());
buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getUserAlias(), c.getPathClasses());
}
if (c instanceof FieldCriteria)
{
FieldCriteria cc = (FieldCriteria) c;
buildJoinTreeForColumn((String) cc.getValue(), useOuterJoin, c.getUserAlias(), c.getPathClasses());
}
}
}
} | java | private void buildJoinTree(Criteria crit)
{
Enumeration e = crit.getElements();
while (e.hasMoreElements())
{
Object o = e.nextElement();
if (o instanceof Criteria)
{
buildJoinTree((Criteria) o);
}
else
{
SelectionCriteria c = (SelectionCriteria) o;
// BRJ skip SqlCriteria
if (c instanceof SqlCriteria)
{
continue;
}
// BRJ: Outer join for OR
boolean useOuterJoin = (crit.getType() == Criteria.OR);
// BRJ: do not build join tree for subQuery attribute
if (c.getAttribute() != null && c.getAttribute() instanceof String)
{
//buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getAlias(), c.getPathClasses());
buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getUserAlias(), c.getPathClasses());
}
if (c instanceof FieldCriteria)
{
FieldCriteria cc = (FieldCriteria) c;
buildJoinTreeForColumn((String) cc.getValue(), useOuterJoin, c.getUserAlias(), c.getPathClasses());
}
}
}
} | [
"private",
"void",
"buildJoinTree",
"(",
"Criteria",
"crit",
")",
"{",
"Enumeration",
"e",
"=",
"crit",
".",
"getElements",
"(",
")",
";",
"while",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"Object",
"o",
"=",
"e",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"o",
"instanceof",
"Criteria",
")",
"{",
"buildJoinTree",
"(",
"(",
"Criteria",
")",
"o",
")",
";",
"}",
"else",
"{",
"SelectionCriteria",
"c",
"=",
"(",
"SelectionCriteria",
")",
"o",
";",
"// BRJ skip SqlCriteria\r",
"if",
"(",
"c",
"instanceof",
"SqlCriteria",
")",
"{",
"continue",
";",
"}",
"// BRJ: Outer join for OR\r",
"boolean",
"useOuterJoin",
"=",
"(",
"crit",
".",
"getType",
"(",
")",
"==",
"Criteria",
".",
"OR",
")",
";",
"// BRJ: do not build join tree for subQuery attribute \r",
"if",
"(",
"c",
".",
"getAttribute",
"(",
")",
"!=",
"null",
"&&",
"c",
".",
"getAttribute",
"(",
")",
"instanceof",
"String",
")",
"{",
"//buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getAlias(), c.getPathClasses());\r",
"buildJoinTreeForColumn",
"(",
"(",
"String",
")",
"c",
".",
"getAttribute",
"(",
")",
",",
"useOuterJoin",
",",
"c",
".",
"getUserAlias",
"(",
")",
",",
"c",
".",
"getPathClasses",
"(",
")",
")",
";",
"}",
"if",
"(",
"c",
"instanceof",
"FieldCriteria",
")",
"{",
"FieldCriteria",
"cc",
"=",
"(",
"FieldCriteria",
")",
"c",
";",
"buildJoinTreeForColumn",
"(",
"(",
"String",
")",
"cc",
".",
"getValue",
"(",
")",
",",
"useOuterJoin",
",",
"c",
".",
"getUserAlias",
"(",
")",
",",
"c",
".",
"getPathClasses",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Build the tree of joins for the given criteria | [
"Build",
"the",
"tree",
"of",
"joins",
"for",
"the",
"given",
"criteria"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1667-L1704 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.buildSuperJoinTree | protected void buildSuperJoinTree(TableAlias left, ClassDescriptor cld, String name, boolean useOuterJoin)
{
ClassDescriptor superCld = cld.getSuperClassDescriptor();
if (superCld != null)
{
SuperReferenceDescriptor superRef = cld.getSuperReference();
FieldDescriptor[] leftFields = superRef.getForeignKeyFieldDescriptors(cld);
TableAlias base_alias = getTableAliasForPath(name, null, null);
String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++;
TableAlias right = new TableAlias(superCld, aliasName, useOuterJoin, null);
Join join1to1 = new Join(left, leftFields, right, superCld.getPkFields(), useOuterJoin, "superClass");
base_alias.addJoin(join1to1);
buildSuperJoinTree(right, superCld, name, useOuterJoin);
}
} | java | protected void buildSuperJoinTree(TableAlias left, ClassDescriptor cld, String name, boolean useOuterJoin)
{
ClassDescriptor superCld = cld.getSuperClassDescriptor();
if (superCld != null)
{
SuperReferenceDescriptor superRef = cld.getSuperReference();
FieldDescriptor[] leftFields = superRef.getForeignKeyFieldDescriptors(cld);
TableAlias base_alias = getTableAliasForPath(name, null, null);
String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++;
TableAlias right = new TableAlias(superCld, aliasName, useOuterJoin, null);
Join join1to1 = new Join(left, leftFields, right, superCld.getPkFields(), useOuterJoin, "superClass");
base_alias.addJoin(join1to1);
buildSuperJoinTree(right, superCld, name, useOuterJoin);
}
} | [
"protected",
"void",
"buildSuperJoinTree",
"(",
"TableAlias",
"left",
",",
"ClassDescriptor",
"cld",
",",
"String",
"name",
",",
"boolean",
"useOuterJoin",
")",
"{",
"ClassDescriptor",
"superCld",
"=",
"cld",
".",
"getSuperClassDescriptor",
"(",
")",
";",
"if",
"(",
"superCld",
"!=",
"null",
")",
"{",
"SuperReferenceDescriptor",
"superRef",
"=",
"cld",
".",
"getSuperReference",
"(",
")",
";",
"FieldDescriptor",
"[",
"]",
"leftFields",
"=",
"superRef",
".",
"getForeignKeyFieldDescriptors",
"(",
"cld",
")",
";",
"TableAlias",
"base_alias",
"=",
"getTableAliasForPath",
"(",
"name",
",",
"null",
",",
"null",
")",
";",
"String",
"aliasName",
"=",
"String",
".",
"valueOf",
"(",
"getAliasChar",
"(",
")",
")",
"+",
"m_aliasCount",
"++",
";",
"TableAlias",
"right",
"=",
"new",
"TableAlias",
"(",
"superCld",
",",
"aliasName",
",",
"useOuterJoin",
",",
"null",
")",
";",
"Join",
"join1to1",
"=",
"new",
"Join",
"(",
"left",
",",
"leftFields",
",",
"right",
",",
"superCld",
".",
"getPkFields",
"(",
")",
",",
"useOuterJoin",
",",
"\"superClass\"",
")",
";",
"base_alias",
".",
"addJoin",
"(",
"join1to1",
")",
";",
"buildSuperJoinTree",
"(",
"right",
",",
"superCld",
",",
"name",
",",
"useOuterJoin",
")",
";",
"}",
"}"
] | build the Join-Information if a super reference exists
@param left
@param cld
@param name | [
"build",
"the",
"Join",
"-",
"Information",
"if",
"a",
"super",
"reference",
"exists"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1730-L1746 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.buildMultiJoinTree | private void buildMultiJoinTree(TableAlias left, ClassDescriptor cld, String name, boolean useOuterJoin)
{
DescriptorRepository repository = cld.getRepository();
Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, false);
for (int i = 0; i < multiJoinedClasses.length; i++)
{
ClassDescriptor subCld = repository.getDescriptorFor(multiJoinedClasses[i]);
SuperReferenceDescriptor srd = subCld.getSuperReference();
if (srd != null)
{
FieldDescriptor[] leftFields = subCld.getPkFields();
FieldDescriptor[] rightFields = srd.getForeignKeyFieldDescriptors(subCld);
TableAlias base_alias = getTableAliasForPath(name, null, null);
String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++;
TableAlias right = new TableAlias(subCld, aliasName, false, null);
Join join1to1 = new Join(left, leftFields, right, rightFields, useOuterJoin, "subClass");
base_alias.addJoin(join1to1);
buildMultiJoinTree(right, subCld, name, useOuterJoin);
}
}
} | java | private void buildMultiJoinTree(TableAlias left, ClassDescriptor cld, String name, boolean useOuterJoin)
{
DescriptorRepository repository = cld.getRepository();
Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, false);
for (int i = 0; i < multiJoinedClasses.length; i++)
{
ClassDescriptor subCld = repository.getDescriptorFor(multiJoinedClasses[i]);
SuperReferenceDescriptor srd = subCld.getSuperReference();
if (srd != null)
{
FieldDescriptor[] leftFields = subCld.getPkFields();
FieldDescriptor[] rightFields = srd.getForeignKeyFieldDescriptors(subCld);
TableAlias base_alias = getTableAliasForPath(name, null, null);
String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++;
TableAlias right = new TableAlias(subCld, aliasName, false, null);
Join join1to1 = new Join(left, leftFields, right, rightFields, useOuterJoin, "subClass");
base_alias.addJoin(join1to1);
buildMultiJoinTree(right, subCld, name, useOuterJoin);
}
}
} | [
"private",
"void",
"buildMultiJoinTree",
"(",
"TableAlias",
"left",
",",
"ClassDescriptor",
"cld",
",",
"String",
"name",
",",
"boolean",
"useOuterJoin",
")",
"{",
"DescriptorRepository",
"repository",
"=",
"cld",
".",
"getRepository",
"(",
")",
";",
"Class",
"[",
"]",
"multiJoinedClasses",
"=",
"repository",
".",
"getSubClassesMultipleJoinedTables",
"(",
"cld",
",",
"false",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"multiJoinedClasses",
".",
"length",
";",
"i",
"++",
")",
"{",
"ClassDescriptor",
"subCld",
"=",
"repository",
".",
"getDescriptorFor",
"(",
"multiJoinedClasses",
"[",
"i",
"]",
")",
";",
"SuperReferenceDescriptor",
"srd",
"=",
"subCld",
".",
"getSuperReference",
"(",
")",
";",
"if",
"(",
"srd",
"!=",
"null",
")",
"{",
"FieldDescriptor",
"[",
"]",
"leftFields",
"=",
"subCld",
".",
"getPkFields",
"(",
")",
";",
"FieldDescriptor",
"[",
"]",
"rightFields",
"=",
"srd",
".",
"getForeignKeyFieldDescriptors",
"(",
"subCld",
")",
";",
"TableAlias",
"base_alias",
"=",
"getTableAliasForPath",
"(",
"name",
",",
"null",
",",
"null",
")",
";",
"String",
"aliasName",
"=",
"String",
".",
"valueOf",
"(",
"getAliasChar",
"(",
")",
")",
"+",
"m_aliasCount",
"++",
";",
"TableAlias",
"right",
"=",
"new",
"TableAlias",
"(",
"subCld",
",",
"aliasName",
",",
"false",
",",
"null",
")",
";",
"Join",
"join1to1",
"=",
"new",
"Join",
"(",
"left",
",",
"leftFields",
",",
"right",
",",
"rightFields",
",",
"useOuterJoin",
",",
"\"subClass\"",
")",
";",
"base_alias",
".",
"addJoin",
"(",
"join1to1",
")",
";",
"buildMultiJoinTree",
"(",
"right",
",",
"subCld",
",",
"name",
",",
"useOuterJoin",
")",
";",
"}",
"}",
"}"
] | build the Join-Information for Subclasses having a super reference to this class
@param left
@param cld
@param name | [
"build",
"the",
"Join",
"-",
"Information",
"for",
"Subclasses",
"having",
"a",
"super",
"reference",
"to",
"this",
"class"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1755-L1779 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.splitCriteria | protected void splitCriteria()
{
Criteria whereCrit = getQuery().getCriteria();
Criteria havingCrit = getQuery().getHavingCriteria();
if (whereCrit == null || whereCrit.isEmpty())
{
getJoinTreeToCriteria().put(getRoot(), null);
}
else
{
// TODO: parameters list shold be modified when the form is reduced to DNF.
getJoinTreeToCriteria().put(getRoot(), whereCrit);
buildJoinTree(whereCrit);
}
if (havingCrit != null && !havingCrit.isEmpty())
{
buildJoinTree(havingCrit);
}
} | java | protected void splitCriteria()
{
Criteria whereCrit = getQuery().getCriteria();
Criteria havingCrit = getQuery().getHavingCriteria();
if (whereCrit == null || whereCrit.isEmpty())
{
getJoinTreeToCriteria().put(getRoot(), null);
}
else
{
// TODO: parameters list shold be modified when the form is reduced to DNF.
getJoinTreeToCriteria().put(getRoot(), whereCrit);
buildJoinTree(whereCrit);
}
if (havingCrit != null && !havingCrit.isEmpty())
{
buildJoinTree(havingCrit);
}
} | [
"protected",
"void",
"splitCriteria",
"(",
")",
"{",
"Criteria",
"whereCrit",
"=",
"getQuery",
"(",
")",
".",
"getCriteria",
"(",
")",
";",
"Criteria",
"havingCrit",
"=",
"getQuery",
"(",
")",
".",
"getHavingCriteria",
"(",
")",
";",
"if",
"(",
"whereCrit",
"==",
"null",
"||",
"whereCrit",
".",
"isEmpty",
"(",
")",
")",
"{",
"getJoinTreeToCriteria",
"(",
")",
".",
"put",
"(",
"getRoot",
"(",
")",
",",
"null",
")",
";",
"}",
"else",
"{",
"// TODO: parameters list shold be modified when the form is reduced to DNF.\r",
"getJoinTreeToCriteria",
"(",
")",
".",
"put",
"(",
"getRoot",
"(",
")",
",",
"whereCrit",
")",
";",
"buildJoinTree",
"(",
"whereCrit",
")",
";",
"}",
"if",
"(",
"havingCrit",
"!=",
"null",
"&&",
"!",
"havingCrit",
".",
"isEmpty",
"(",
")",
")",
"{",
"buildJoinTree",
"(",
"havingCrit",
")",
";",
"}",
"}"
] | First reduce the Criteria to the normal disjunctive form, then
calculate the necessary tree of joined tables for each item, then group
items with the same tree of joined tables. | [
"First",
"reduce",
"the",
"Criteria",
"to",
"the",
"normal",
"disjunctive",
"form",
"then",
"calculate",
"the",
"necessary",
"tree",
"of",
"joined",
"tables",
"for",
"each",
"item",
"then",
"group",
"items",
"with",
"the",
"same",
"tree",
"of",
"joined",
"tables",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1786-L1807 | train |
geomajas/geomajas-project-server | plugin/reporting/reporting/src/main/java/org/geomajas/plugin/reporting/command/reporting/PrepareReportingCommand.java | PrepareReportingCommand.getFilter | private Filter getFilter(String layerFilter, String[] featureIds) throws GeomajasException {
Filter filter = null;
if (null != layerFilter) {
filter = filterService.parseFilter(layerFilter);
}
if (null != featureIds) {
Filter fidFilter = filterService.createFidFilter(featureIds);
if (null == filter) {
filter = fidFilter;
} else {
filter = filterService.createAndFilter(filter, fidFilter);
}
}
return filter;
} | java | private Filter getFilter(String layerFilter, String[] featureIds) throws GeomajasException {
Filter filter = null;
if (null != layerFilter) {
filter = filterService.parseFilter(layerFilter);
}
if (null != featureIds) {
Filter fidFilter = filterService.createFidFilter(featureIds);
if (null == filter) {
filter = fidFilter;
} else {
filter = filterService.createAndFilter(filter, fidFilter);
}
}
return filter;
} | [
"private",
"Filter",
"getFilter",
"(",
"String",
"layerFilter",
",",
"String",
"[",
"]",
"featureIds",
")",
"throws",
"GeomajasException",
"{",
"Filter",
"filter",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"layerFilter",
")",
"{",
"filter",
"=",
"filterService",
".",
"parseFilter",
"(",
"layerFilter",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"featureIds",
")",
"{",
"Filter",
"fidFilter",
"=",
"filterService",
".",
"createFidFilter",
"(",
"featureIds",
")",
";",
"if",
"(",
"null",
"==",
"filter",
")",
"{",
"filter",
"=",
"fidFilter",
";",
"}",
"else",
"{",
"filter",
"=",
"filterService",
".",
"createAndFilter",
"(",
"filter",
",",
"fidFilter",
")",
";",
"}",
"}",
"return",
"filter",
";",
"}"
] | Build filter for the request.
@param layerFilter layer filter
@param featureIds features to include in report (null for all)
@return filter
@throws GeomajasException filter could not be parsed/created | [
"Build",
"filter",
"for",
"the",
"request",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/reporting/reporting/src/main/java/org/geomajas/plugin/reporting/command/reporting/PrepareReportingCommand.java#L190-L204 | train |
geomajas/geomajas-project-server | plugin/layer-tms/tms/src/main/java/org/geomajas/layer/tms/tile/TileMapUrlBuilder.java | TileMapUrlBuilder.resolveProxyUrl | public static String resolveProxyUrl(String relativeUrl, TileMap tileMap, String baseTmsUrl) {
TileCode tc = parseTileCode(relativeUrl);
return buildUrl(tc, tileMap, baseTmsUrl);
} | java | public static String resolveProxyUrl(String relativeUrl, TileMap tileMap, String baseTmsUrl) {
TileCode tc = parseTileCode(relativeUrl);
return buildUrl(tc, tileMap, baseTmsUrl);
} | [
"public",
"static",
"String",
"resolveProxyUrl",
"(",
"String",
"relativeUrl",
",",
"TileMap",
"tileMap",
",",
"String",
"baseTmsUrl",
")",
"{",
"TileCode",
"tc",
"=",
"parseTileCode",
"(",
"relativeUrl",
")",
";",
"return",
"buildUrl",
"(",
"tc",
",",
"tileMap",
",",
"baseTmsUrl",
")",
";",
"}"
] | Replaces the proxy url with the correct url from the tileMap.
@return correct url to TMS service | [
"Replaces",
"the",
"proxy",
"url",
"with",
"the",
"correct",
"url",
"from",
"the",
"tileMap",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/layer-tms/tms/src/main/java/org/geomajas/layer/tms/tile/TileMapUrlBuilder.java#L48-L51 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java | GraphsHandler.getModuleGraph | public AbstractGraph getModuleGraph(final String moduleId) {
final ModuleHandler moduleHandler = new ModuleHandler(repoHandler);
final DbModule module = moduleHandler.getModule(moduleId);
final DbOrganization organization = moduleHandler.getOrganization(module);
filters.setCorporateFilter(new CorporateFilter(organization));
final AbstractGraph graph = new ModuleGraph();
addModuleToGraph(module, graph, 0);
return graph;
} | java | public AbstractGraph getModuleGraph(final String moduleId) {
final ModuleHandler moduleHandler = new ModuleHandler(repoHandler);
final DbModule module = moduleHandler.getModule(moduleId);
final DbOrganization organization = moduleHandler.getOrganization(module);
filters.setCorporateFilter(new CorporateFilter(organization));
final AbstractGraph graph = new ModuleGraph();
addModuleToGraph(module, graph, 0);
return graph;
} | [
"public",
"AbstractGraph",
"getModuleGraph",
"(",
"final",
"String",
"moduleId",
")",
"{",
"final",
"ModuleHandler",
"moduleHandler",
"=",
"new",
"ModuleHandler",
"(",
"repoHandler",
")",
";",
"final",
"DbModule",
"module",
"=",
"moduleHandler",
".",
"getModule",
"(",
"moduleId",
")",
";",
"final",
"DbOrganization",
"organization",
"=",
"moduleHandler",
".",
"getOrganization",
"(",
"module",
")",
";",
"filters",
".",
"setCorporateFilter",
"(",
"new",
"CorporateFilter",
"(",
"organization",
")",
")",
";",
"final",
"AbstractGraph",
"graph",
"=",
"new",
"ModuleGraph",
"(",
")",
";",
"addModuleToGraph",
"(",
"module",
",",
"graph",
",",
"0",
")",
";",
"return",
"graph",
";",
"}"
] | Generate a module graph regarding the filters
@param moduleId String
@return AbstractGraph | [
"Generate",
"a",
"module",
"graph",
"regarding",
"the",
"filters"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java#L45-L56 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java | GraphsHandler.addModuleToGraph | private void addModuleToGraph(final DbModule module, final AbstractGraph graph, final int depth) {
if (graph.isTreated(graph.getId(module))) {
return;
}
final String moduleElementId = graph.getId(module);
graph.addElement(moduleElementId, module.getVersion(), depth == 0);
if (filters.getDepthHandler().shouldGoDeeper(depth)) {
for (final DbDependency dep : DataUtils.getAllDbDependencies(module)) {
if(filters.shouldBeInReport(dep)){
addDependencyToGraph(dep, graph, depth + 1, moduleElementId);
}
}
}
} | java | private void addModuleToGraph(final DbModule module, final AbstractGraph graph, final int depth) {
if (graph.isTreated(graph.getId(module))) {
return;
}
final String moduleElementId = graph.getId(module);
graph.addElement(moduleElementId, module.getVersion(), depth == 0);
if (filters.getDepthHandler().shouldGoDeeper(depth)) {
for (final DbDependency dep : DataUtils.getAllDbDependencies(module)) {
if(filters.shouldBeInReport(dep)){
addDependencyToGraph(dep, graph, depth + 1, moduleElementId);
}
}
}
} | [
"private",
"void",
"addModuleToGraph",
"(",
"final",
"DbModule",
"module",
",",
"final",
"AbstractGraph",
"graph",
",",
"final",
"int",
"depth",
")",
"{",
"if",
"(",
"graph",
".",
"isTreated",
"(",
"graph",
".",
"getId",
"(",
"module",
")",
")",
")",
"{",
"return",
";",
"}",
"final",
"String",
"moduleElementId",
"=",
"graph",
".",
"getId",
"(",
"module",
")",
";",
"graph",
".",
"addElement",
"(",
"moduleElementId",
",",
"module",
".",
"getVersion",
"(",
")",
",",
"depth",
"==",
"0",
")",
";",
"if",
"(",
"filters",
".",
"getDepthHandler",
"(",
")",
".",
"shouldGoDeeper",
"(",
"depth",
")",
")",
"{",
"for",
"(",
"final",
"DbDependency",
"dep",
":",
"DataUtils",
".",
"getAllDbDependencies",
"(",
"module",
")",
")",
"{",
"if",
"(",
"filters",
".",
"shouldBeInReport",
"(",
"dep",
")",
")",
"{",
"addDependencyToGraph",
"(",
"dep",
",",
"graph",
",",
"depth",
"+",
"1",
",",
"moduleElementId",
")",
";",
"}",
"}",
"}",
"}"
] | Manage the artifact add to the Module AbstractGraph
@param graph
@param depth | [
"Manage",
"the",
"artifact",
"add",
"to",
"the",
"Module",
"AbstractGraph"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java#L64-L79 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java | GraphsHandler.addDependencyToGraph | private void addDependencyToGraph(final DbDependency dependency, final AbstractGraph graph, final int depth, final String parentId) {
// In that case of Axway artifact we will add a module to the graph
if (filters.getCorporateFilter().filter(dependency)) {
final DbModule dbTarget = repoHandler.getModuleOf(dependency.getTarget());
// if there is no module, add the artifact to the graph
if(dbTarget == null){
LOG.error("Got missing reference: " + dependency.getTarget());
final DbArtifact dbArtifact = DataUtils.createDbArtifact(dependency.getTarget());
final String targetElementId = graph.getId(dbArtifact);
graph.addElement(targetElementId, dbArtifact.getVersion(), false);
graph.addDependency(parentId, targetElementId, dependency.getScope());
return;
}
// Add the element to the graph
addModuleToGraph(dbTarget, graph, depth + 1);
//Add the dependency to the graph
final String moduleElementId = graph.getId(dbTarget);
graph.addDependency(parentId, moduleElementId, dependency.getScope());
}
// In case a third-party we will add an artifact
else {
final DbArtifact dbTarget = repoHandler.getArtifact(dependency.getTarget());
if(dbTarget == null){
LOG.error("Got missing artifact: " + dependency.getTarget());
return;
}
if(!graph.isTreated(graph.getId(dbTarget))){
final ModelMapper modelMapper = new ModelMapper(repoHandler);
final Artifact target = modelMapper.getArtifact(dbTarget);
final String targetElementId = graph.getId(target);
graph.addElement(targetElementId, target.getVersion(), false);
graph.addDependency(parentId, targetElementId, dependency.getScope());
}
}
} | java | private void addDependencyToGraph(final DbDependency dependency, final AbstractGraph graph, final int depth, final String parentId) {
// In that case of Axway artifact we will add a module to the graph
if (filters.getCorporateFilter().filter(dependency)) {
final DbModule dbTarget = repoHandler.getModuleOf(dependency.getTarget());
// if there is no module, add the artifact to the graph
if(dbTarget == null){
LOG.error("Got missing reference: " + dependency.getTarget());
final DbArtifact dbArtifact = DataUtils.createDbArtifact(dependency.getTarget());
final String targetElementId = graph.getId(dbArtifact);
graph.addElement(targetElementId, dbArtifact.getVersion(), false);
graph.addDependency(parentId, targetElementId, dependency.getScope());
return;
}
// Add the element to the graph
addModuleToGraph(dbTarget, graph, depth + 1);
//Add the dependency to the graph
final String moduleElementId = graph.getId(dbTarget);
graph.addDependency(parentId, moduleElementId, dependency.getScope());
}
// In case a third-party we will add an artifact
else {
final DbArtifact dbTarget = repoHandler.getArtifact(dependency.getTarget());
if(dbTarget == null){
LOG.error("Got missing artifact: " + dependency.getTarget());
return;
}
if(!graph.isTreated(graph.getId(dbTarget))){
final ModelMapper modelMapper = new ModelMapper(repoHandler);
final Artifact target = modelMapper.getArtifact(dbTarget);
final String targetElementId = graph.getId(target);
graph.addElement(targetElementId, target.getVersion(), false);
graph.addDependency(parentId, targetElementId, dependency.getScope());
}
}
} | [
"private",
"void",
"addDependencyToGraph",
"(",
"final",
"DbDependency",
"dependency",
",",
"final",
"AbstractGraph",
"graph",
",",
"final",
"int",
"depth",
",",
"final",
"String",
"parentId",
")",
"{",
"// In that case of Axway artifact we will add a module to the graph",
"if",
"(",
"filters",
".",
"getCorporateFilter",
"(",
")",
".",
"filter",
"(",
"dependency",
")",
")",
"{",
"final",
"DbModule",
"dbTarget",
"=",
"repoHandler",
".",
"getModuleOf",
"(",
"dependency",
".",
"getTarget",
"(",
")",
")",
";",
"// if there is no module, add the artifact to the graph",
"if",
"(",
"dbTarget",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Got missing reference: \"",
"+",
"dependency",
".",
"getTarget",
"(",
")",
")",
";",
"final",
"DbArtifact",
"dbArtifact",
"=",
"DataUtils",
".",
"createDbArtifact",
"(",
"dependency",
".",
"getTarget",
"(",
")",
")",
";",
"final",
"String",
"targetElementId",
"=",
"graph",
".",
"getId",
"(",
"dbArtifact",
")",
";",
"graph",
".",
"addElement",
"(",
"targetElementId",
",",
"dbArtifact",
".",
"getVersion",
"(",
")",
",",
"false",
")",
";",
"graph",
".",
"addDependency",
"(",
"parentId",
",",
"targetElementId",
",",
"dependency",
".",
"getScope",
"(",
")",
")",
";",
"return",
";",
"}",
"// Add the element to the graph",
"addModuleToGraph",
"(",
"dbTarget",
",",
"graph",
",",
"depth",
"+",
"1",
")",
";",
"//Add the dependency to the graph",
"final",
"String",
"moduleElementId",
"=",
"graph",
".",
"getId",
"(",
"dbTarget",
")",
";",
"graph",
".",
"addDependency",
"(",
"parentId",
",",
"moduleElementId",
",",
"dependency",
".",
"getScope",
"(",
")",
")",
";",
"}",
"// In case a third-party we will add an artifact",
"else",
"{",
"final",
"DbArtifact",
"dbTarget",
"=",
"repoHandler",
".",
"getArtifact",
"(",
"dependency",
".",
"getTarget",
"(",
")",
")",
";",
"if",
"(",
"dbTarget",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Got missing artifact: \"",
"+",
"dependency",
".",
"getTarget",
"(",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"graph",
".",
"isTreated",
"(",
"graph",
".",
"getId",
"(",
"dbTarget",
")",
")",
")",
"{",
"final",
"ModelMapper",
"modelMapper",
"=",
"new",
"ModelMapper",
"(",
"repoHandler",
")",
";",
"final",
"Artifact",
"target",
"=",
"modelMapper",
".",
"getArtifact",
"(",
"dbTarget",
")",
";",
"final",
"String",
"targetElementId",
"=",
"graph",
".",
"getId",
"(",
"target",
")",
";",
"graph",
".",
"addElement",
"(",
"targetElementId",
",",
"target",
".",
"getVersion",
"(",
")",
",",
"false",
")",
";",
"graph",
".",
"addDependency",
"(",
"parentId",
",",
"targetElementId",
",",
"dependency",
".",
"getScope",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Add a dependency to the graph
@param dependency
@param graph
@param depth
@param parentId | [
"Add",
"a",
"dependency",
"to",
"the",
"graph"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java#L89-L127 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java | GraphsHandler.getModuleTree | public TreeNode getModuleTree(final String moduleId) {
final ModuleHandler moduleHandler = new ModuleHandler(repoHandler);
final DbModule module = moduleHandler.getModule(moduleId);
final TreeNode tree = new TreeNode();
tree.setName(module.getName());
// Add submodules
for (final DbModule submodule : module.getSubmodules()) {
addModuleToTree(submodule, tree);
}
return tree;
} | java | public TreeNode getModuleTree(final String moduleId) {
final ModuleHandler moduleHandler = new ModuleHandler(repoHandler);
final DbModule module = moduleHandler.getModule(moduleId);
final TreeNode tree = new TreeNode();
tree.setName(module.getName());
// Add submodules
for (final DbModule submodule : module.getSubmodules()) {
addModuleToTree(submodule, tree);
}
return tree;
} | [
"public",
"TreeNode",
"getModuleTree",
"(",
"final",
"String",
"moduleId",
")",
"{",
"final",
"ModuleHandler",
"moduleHandler",
"=",
"new",
"ModuleHandler",
"(",
"repoHandler",
")",
";",
"final",
"DbModule",
"module",
"=",
"moduleHandler",
".",
"getModule",
"(",
"moduleId",
")",
";",
"final",
"TreeNode",
"tree",
"=",
"new",
"TreeNode",
"(",
")",
";",
"tree",
".",
"setName",
"(",
"module",
".",
"getName",
"(",
")",
")",
";",
"// Add submodules",
"for",
"(",
"final",
"DbModule",
"submodule",
":",
"module",
".",
"getSubmodules",
"(",
")",
")",
"{",
"addModuleToTree",
"(",
"submodule",
",",
"tree",
")",
";",
"}",
"return",
"tree",
";",
"}"
] | Generate a groupId tree regarding the filters
@param moduleId
@return TreeNode | [
"Generate",
"a",
"groupId",
"tree",
"regarding",
"the",
"filters"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java#L135-L148 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java | GraphsHandler.addModuleToTree | private void addModuleToTree(final DbModule module, final TreeNode tree) {
final TreeNode subTree = new TreeNode();
subTree.setName(module.getName());
tree.addChild(subTree);
// Add SubsubModules
for (final DbModule subsubmodule : module.getSubmodules()) {
addModuleToTree(subsubmodule, subTree);
}
} | java | private void addModuleToTree(final DbModule module, final TreeNode tree) {
final TreeNode subTree = new TreeNode();
subTree.setName(module.getName());
tree.addChild(subTree);
// Add SubsubModules
for (final DbModule subsubmodule : module.getSubmodules()) {
addModuleToTree(subsubmodule, subTree);
}
} | [
"private",
"void",
"addModuleToTree",
"(",
"final",
"DbModule",
"module",
",",
"final",
"TreeNode",
"tree",
")",
"{",
"final",
"TreeNode",
"subTree",
"=",
"new",
"TreeNode",
"(",
")",
";",
"subTree",
".",
"setName",
"(",
"module",
".",
"getName",
"(",
")",
")",
";",
"tree",
".",
"addChild",
"(",
"subTree",
")",
";",
"// Add SubsubModules",
"for",
"(",
"final",
"DbModule",
"subsubmodule",
":",
"module",
".",
"getSubmodules",
"(",
")",
")",
"{",
"addModuleToTree",
"(",
"subsubmodule",
",",
"subTree",
")",
";",
"}",
"}"
] | Add a module to a module tree
@param module
@param tree | [
"Add",
"a",
"module",
"to",
"a",
"module",
"tree"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/GraphsHandler.java#L156-L165 | train |
gsi-upm/BeastTool | beast-tool/src/main/java/es/upm/dit/gsi/beast/reader/mas/MASReader.java | MASReader.main | public static void main(String[] args) throws Exception {
Logger logger = Logger.getLogger("MASReader.main");
Properties beastConfigProperties = new Properties();
String beastConfigPropertiesFile = null;
if (args.length > 0) {
beastConfigPropertiesFile = args[0];
beastConfigProperties.load(new FileInputStream(
beastConfigPropertiesFile));
logger.info("Properties file selected -> "
+ beastConfigPropertiesFile);
} else {
logger.severe("No properties file found. Set the path of properties file as argument.");
throw new BeastException(
"No properties file found. Set the path of properties file as argument.");
}
String loggerConfigPropertiesFile;
if (args.length > 1) {
Properties loggerConfigProperties = new Properties();
loggerConfigPropertiesFile = args[1];
try {
FileInputStream loggerConfigFile = new FileInputStream(
loggerConfigPropertiesFile);
loggerConfigProperties.load(loggerConfigFile);
LogManager.getLogManager().readConfiguration(loggerConfigFile);
logger.info("Logging properties configured successfully. Logger config file: "
+ loggerConfigPropertiesFile);
} catch (IOException ex) {
logger.warning("WARNING: Could not open configuration file");
logger.warning("WARNING: Logging not configured (console output only)");
}
} else {
loggerConfigPropertiesFile = null;
}
MASReader.generateJavaFiles(
beastConfigProperties.getProperty("requirementsFolder"), "\""
+ beastConfigProperties.getProperty("MASPlatform")
+ "\"",
beastConfigProperties.getProperty("srcTestRootFolder"),
beastConfigProperties.getProperty("storiesPackage"),
beastConfigProperties.getProperty("caseManagerPackage"),
loggerConfigPropertiesFile,
beastConfigProperties.getProperty("specificationPhase"));
} | java | public static void main(String[] args) throws Exception {
Logger logger = Logger.getLogger("MASReader.main");
Properties beastConfigProperties = new Properties();
String beastConfigPropertiesFile = null;
if (args.length > 0) {
beastConfigPropertiesFile = args[0];
beastConfigProperties.load(new FileInputStream(
beastConfigPropertiesFile));
logger.info("Properties file selected -> "
+ beastConfigPropertiesFile);
} else {
logger.severe("No properties file found. Set the path of properties file as argument.");
throw new BeastException(
"No properties file found. Set the path of properties file as argument.");
}
String loggerConfigPropertiesFile;
if (args.length > 1) {
Properties loggerConfigProperties = new Properties();
loggerConfigPropertiesFile = args[1];
try {
FileInputStream loggerConfigFile = new FileInputStream(
loggerConfigPropertiesFile);
loggerConfigProperties.load(loggerConfigFile);
LogManager.getLogManager().readConfiguration(loggerConfigFile);
logger.info("Logging properties configured successfully. Logger config file: "
+ loggerConfigPropertiesFile);
} catch (IOException ex) {
logger.warning("WARNING: Could not open configuration file");
logger.warning("WARNING: Logging not configured (console output only)");
}
} else {
loggerConfigPropertiesFile = null;
}
MASReader.generateJavaFiles(
beastConfigProperties.getProperty("requirementsFolder"), "\""
+ beastConfigProperties.getProperty("MASPlatform")
+ "\"",
beastConfigProperties.getProperty("srcTestRootFolder"),
beastConfigProperties.getProperty("storiesPackage"),
beastConfigProperties.getProperty("caseManagerPackage"),
loggerConfigPropertiesFile,
beastConfigProperties.getProperty("specificationPhase"));
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"MASReader.main\"",
")",
";",
"Properties",
"beastConfigProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"String",
"beastConfigPropertiesFile",
"=",
"null",
";",
"if",
"(",
"args",
".",
"length",
">",
"0",
")",
"{",
"beastConfigPropertiesFile",
"=",
"args",
"[",
"0",
"]",
";",
"beastConfigProperties",
".",
"load",
"(",
"new",
"FileInputStream",
"(",
"beastConfigPropertiesFile",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"Properties file selected -> \"",
"+",
"beastConfigPropertiesFile",
")",
";",
"}",
"else",
"{",
"logger",
".",
"severe",
"(",
"\"No properties file found. Set the path of properties file as argument.\"",
")",
";",
"throw",
"new",
"BeastException",
"(",
"\"No properties file found. Set the path of properties file as argument.\"",
")",
";",
"}",
"String",
"loggerConfigPropertiesFile",
";",
"if",
"(",
"args",
".",
"length",
">",
"1",
")",
"{",
"Properties",
"loggerConfigProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"loggerConfigPropertiesFile",
"=",
"args",
"[",
"1",
"]",
";",
"try",
"{",
"FileInputStream",
"loggerConfigFile",
"=",
"new",
"FileInputStream",
"(",
"loggerConfigPropertiesFile",
")",
";",
"loggerConfigProperties",
".",
"load",
"(",
"loggerConfigFile",
")",
";",
"LogManager",
".",
"getLogManager",
"(",
")",
".",
"readConfiguration",
"(",
"loggerConfigFile",
")",
";",
"logger",
".",
"info",
"(",
"\"Logging properties configured successfully. Logger config file: \"",
"+",
"loggerConfigPropertiesFile",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"logger",
".",
"warning",
"(",
"\"WARNING: Could not open configuration file\"",
")",
";",
"logger",
".",
"warning",
"(",
"\"WARNING: Logging not configured (console output only)\"",
")",
";",
"}",
"}",
"else",
"{",
"loggerConfigPropertiesFile",
"=",
"null",
";",
"}",
"MASReader",
".",
"generateJavaFiles",
"(",
"beastConfigProperties",
".",
"getProperty",
"(",
"\"requirementsFolder\"",
")",
",",
"\"\\\"\"",
"+",
"beastConfigProperties",
".",
"getProperty",
"(",
"\"MASPlatform\"",
")",
"+",
"\"\\\"\"",
",",
"beastConfigProperties",
".",
"getProperty",
"(",
"\"srcTestRootFolder\"",
")",
",",
"beastConfigProperties",
".",
"getProperty",
"(",
"\"storiesPackage\"",
")",
",",
"beastConfigProperties",
".",
"getProperty",
"(",
"\"caseManagerPackage\"",
")",
",",
"loggerConfigPropertiesFile",
",",
"beastConfigProperties",
".",
"getProperty",
"(",
"\"specificationPhase\"",
")",
")",
";",
"}"
] | Main method to start reading the plain text given by the client
@param args
, where arg[0] is Beast configuration file (beast.properties)
and arg[1] is Logger configuration file (logger.properties)
@throws Exception | [
"Main",
"method",
"to",
"start",
"reading",
"the",
"plain",
"text",
"given",
"by",
"the",
"client"
] | cc7fdc75cb818c5d60802aaf32c27829e0ca144c | https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/reader/mas/MASReader.java#L361-L406 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.getIndirectionHandlerConstructor | private synchronized Constructor getIndirectionHandlerConstructor()
{
if(_indirectionHandlerConstructor == null)
{
Class[] paramType = {PBKey.class, Identity.class};
try
{
_indirectionHandlerConstructor = getIndirectionHandlerClass().getConstructor(paramType);
}
catch(NoSuchMethodException ex)
{
throw new MetadataException("The class "
+ _indirectionHandlerClass.getName()
+ " specified for IndirectionHandlerClass"
+ " is required to have a public constructor with signature ("
+ PBKey.class.getName()
+ ", "
+ Identity.class.getName()
+ ").");
}
}
return _indirectionHandlerConstructor;
} | java | private synchronized Constructor getIndirectionHandlerConstructor()
{
if(_indirectionHandlerConstructor == null)
{
Class[] paramType = {PBKey.class, Identity.class};
try
{
_indirectionHandlerConstructor = getIndirectionHandlerClass().getConstructor(paramType);
}
catch(NoSuchMethodException ex)
{
throw new MetadataException("The class "
+ _indirectionHandlerClass.getName()
+ " specified for IndirectionHandlerClass"
+ " is required to have a public constructor with signature ("
+ PBKey.class.getName()
+ ", "
+ Identity.class.getName()
+ ").");
}
}
return _indirectionHandlerConstructor;
} | [
"private",
"synchronized",
"Constructor",
"getIndirectionHandlerConstructor",
"(",
")",
"{",
"if",
"(",
"_indirectionHandlerConstructor",
"==",
"null",
")",
"{",
"Class",
"[",
"]",
"paramType",
"=",
"{",
"PBKey",
".",
"class",
",",
"Identity",
".",
"class",
"}",
";",
"try",
"{",
"_indirectionHandlerConstructor",
"=",
"getIndirectionHandlerClass",
"(",
")",
".",
"getConstructor",
"(",
"paramType",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"The class \"",
"+",
"_indirectionHandlerClass",
".",
"getName",
"(",
")",
"+",
"\" specified for IndirectionHandlerClass\"",
"+",
"\" is required to have a public constructor with signature (\"",
"+",
"PBKey",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\", \"",
"+",
"Identity",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\").\"",
")",
";",
"}",
"}",
"return",
"_indirectionHandlerConstructor",
";",
"}"
] | Returns the constructor of the indirection handler class.
@return The constructor for indirection handlers | [
"Returns",
"the",
"constructor",
"of",
"the",
"indirection",
"handler",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L73-L96 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.setIndirectionHandlerClass | public void setIndirectionHandlerClass(Class indirectionHandlerClass)
{
if(indirectionHandlerClass == null)
{
//throw new MetadataException("No IndirectionHandlerClass specified.");
/**
* andrew.clute
* Allow the default IndirectionHandler for the given ProxyFactory implementation
* when the parameter is not given
*/
indirectionHandlerClass = getDefaultIndirectionHandlerClass();
}
if(indirectionHandlerClass.isInterface()
|| Modifier.isAbstract(indirectionHandlerClass.getModifiers())
|| !getIndirectionHandlerBaseClass().isAssignableFrom(indirectionHandlerClass))
{
throw new MetadataException("Illegal class "
+ indirectionHandlerClass.getName()
+ " specified for IndirectionHandlerClass. Must be a concrete subclass of "
+ getIndirectionHandlerBaseClass().getName());
}
_indirectionHandlerClass = indirectionHandlerClass;
} | java | public void setIndirectionHandlerClass(Class indirectionHandlerClass)
{
if(indirectionHandlerClass == null)
{
//throw new MetadataException("No IndirectionHandlerClass specified.");
/**
* andrew.clute
* Allow the default IndirectionHandler for the given ProxyFactory implementation
* when the parameter is not given
*/
indirectionHandlerClass = getDefaultIndirectionHandlerClass();
}
if(indirectionHandlerClass.isInterface()
|| Modifier.isAbstract(indirectionHandlerClass.getModifiers())
|| !getIndirectionHandlerBaseClass().isAssignableFrom(indirectionHandlerClass))
{
throw new MetadataException("Illegal class "
+ indirectionHandlerClass.getName()
+ " specified for IndirectionHandlerClass. Must be a concrete subclass of "
+ getIndirectionHandlerBaseClass().getName());
}
_indirectionHandlerClass = indirectionHandlerClass;
} | [
"public",
"void",
"setIndirectionHandlerClass",
"(",
"Class",
"indirectionHandlerClass",
")",
"{",
"if",
"(",
"indirectionHandlerClass",
"==",
"null",
")",
"{",
"//throw new MetadataException(\"No IndirectionHandlerClass specified.\");\r",
"/**\r\n * andrew.clute\r\n * Allow the default IndirectionHandler for the given ProxyFactory implementation\r\n * when the parameter is not given\r\n */",
"indirectionHandlerClass",
"=",
"getDefaultIndirectionHandlerClass",
"(",
")",
";",
"}",
"if",
"(",
"indirectionHandlerClass",
".",
"isInterface",
"(",
")",
"||",
"Modifier",
".",
"isAbstract",
"(",
"indirectionHandlerClass",
".",
"getModifiers",
"(",
")",
")",
"||",
"!",
"getIndirectionHandlerBaseClass",
"(",
")",
".",
"isAssignableFrom",
"(",
"indirectionHandlerClass",
")",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"Illegal class \"",
"+",
"indirectionHandlerClass",
".",
"getName",
"(",
")",
"+",
"\" specified for IndirectionHandlerClass. Must be a concrete subclass of \"",
"+",
"getIndirectionHandlerBaseClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"_indirectionHandlerClass",
"=",
"indirectionHandlerClass",
";",
"}"
] | Sets the indirection handler class.
@param indirectionHandlerClass The class for indirection handlers | [
"Sets",
"the",
"indirection",
"handler",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L118-L140 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.createIndirectionHandler | public IndirectionHandler createIndirectionHandler(PBKey brokerKey, Identity id)
{
Object args[] = {brokerKey, id};
try
{
return (IndirectionHandler) getIndirectionHandlerConstructor().newInstance(args);
}
catch(InvocationTargetException ex)
{
throw new PersistenceBrokerException("Exception while creating a new indirection handler instance", ex);
}
catch(InstantiationException ex)
{
throw new PersistenceBrokerException("Exception while creating a new indirection handler instance", ex);
}
catch(IllegalAccessException ex)
{
throw new PersistenceBrokerException("Exception while creating a new indirection handler instance", ex);
}
} | java | public IndirectionHandler createIndirectionHandler(PBKey brokerKey, Identity id)
{
Object args[] = {brokerKey, id};
try
{
return (IndirectionHandler) getIndirectionHandlerConstructor().newInstance(args);
}
catch(InvocationTargetException ex)
{
throw new PersistenceBrokerException("Exception while creating a new indirection handler instance", ex);
}
catch(InstantiationException ex)
{
throw new PersistenceBrokerException("Exception while creating a new indirection handler instance", ex);
}
catch(IllegalAccessException ex)
{
throw new PersistenceBrokerException("Exception while creating a new indirection handler instance", ex);
}
} | [
"public",
"IndirectionHandler",
"createIndirectionHandler",
"(",
"PBKey",
"brokerKey",
",",
"Identity",
"id",
")",
"{",
"Object",
"args",
"[",
"]",
"=",
"{",
"brokerKey",
",",
"id",
"}",
";",
"try",
"{",
"return",
"(",
"IndirectionHandler",
")",
"getIndirectionHandlerConstructor",
"(",
")",
".",
"newInstance",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Exception while creating a new indirection handler instance\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Exception while creating a new indirection handler instance\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Exception while creating a new indirection handler instance\"",
",",
"ex",
")",
";",
"}",
"}"
] | Creates a new indirection handler instance.
@param brokerKey The associated {@link PBKey}.
@param id The subject's ids
@return The new instance | [
"Creates",
"a",
"new",
"indirection",
"handler",
"instance",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L149-L169 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.retrieveCollectionProxyConstructor | private static Constructor retrieveCollectionProxyConstructor(Class proxyClass, Class baseType, String typeDesc)
{
if(proxyClass == null)
{
throw new MetadataException("No " + typeDesc + " specified.");
}
if(proxyClass.isInterface() || Modifier.isAbstract(proxyClass.getModifiers()) || !baseType.isAssignableFrom(proxyClass))
{
throw new MetadataException("Illegal class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ ". Must be a concrete subclass of "
+ baseType.getName());
}
Class[] paramType = {PBKey.class, Class.class, Query.class};
try
{
return proxyClass.getConstructor(paramType);
}
catch(NoSuchMethodException ex)
{
throw new MetadataException("The class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ " is required to have a public constructor with signature ("
+ PBKey.class.getName()
+ ", "
+ Class.class.getName()
+ ", "
+ Query.class.getName()
+ ").");
}
} | java | private static Constructor retrieveCollectionProxyConstructor(Class proxyClass, Class baseType, String typeDesc)
{
if(proxyClass == null)
{
throw new MetadataException("No " + typeDesc + " specified.");
}
if(proxyClass.isInterface() || Modifier.isAbstract(proxyClass.getModifiers()) || !baseType.isAssignableFrom(proxyClass))
{
throw new MetadataException("Illegal class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ ". Must be a concrete subclass of "
+ baseType.getName());
}
Class[] paramType = {PBKey.class, Class.class, Query.class};
try
{
return proxyClass.getConstructor(paramType);
}
catch(NoSuchMethodException ex)
{
throw new MetadataException("The class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ " is required to have a public constructor with signature ("
+ PBKey.class.getName()
+ ", "
+ Class.class.getName()
+ ", "
+ Query.class.getName()
+ ").");
}
} | [
"private",
"static",
"Constructor",
"retrieveCollectionProxyConstructor",
"(",
"Class",
"proxyClass",
",",
"Class",
"baseType",
",",
"String",
"typeDesc",
")",
"{",
"if",
"(",
"proxyClass",
"==",
"null",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"No \"",
"+",
"typeDesc",
"+",
"\" specified.\"",
")",
";",
"}",
"if",
"(",
"proxyClass",
".",
"isInterface",
"(",
")",
"||",
"Modifier",
".",
"isAbstract",
"(",
"proxyClass",
".",
"getModifiers",
"(",
")",
")",
"||",
"!",
"baseType",
".",
"isAssignableFrom",
"(",
"proxyClass",
")",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"Illegal class \"",
"+",
"proxyClass",
".",
"getName",
"(",
")",
"+",
"\" specified for \"",
"+",
"typeDesc",
"+",
"\". Must be a concrete subclass of \"",
"+",
"baseType",
".",
"getName",
"(",
")",
")",
";",
"}",
"Class",
"[",
"]",
"paramType",
"=",
"{",
"PBKey",
".",
"class",
",",
"Class",
".",
"class",
",",
"Query",
".",
"class",
"}",
";",
"try",
"{",
"return",
"proxyClass",
".",
"getConstructor",
"(",
"paramType",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"The class \"",
"+",
"proxyClass",
".",
"getName",
"(",
")",
"+",
"\" specified for \"",
"+",
"typeDesc",
"+",
"\" is required to have a public constructor with signature (\"",
"+",
"PBKey",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\", \"",
"+",
"Class",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\", \"",
"+",
"Query",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\").\"",
")",
";",
"}",
"}"
] | Retrieves the constructor that is used by OJB to create instances of the given collection proxy
class.
@param proxyClass The proxy class
@param baseType The required base type of the proxy class
@param typeDesc The type of collection proxy
@return The constructor | [
"Retrieves",
"the",
"constructor",
"that",
"is",
"used",
"by",
"OJB",
"to",
"create",
"instances",
"of",
"the",
"given",
"collection",
"proxy",
"class",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L180-L216 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.createCollectionProxy | public ManageableCollection createCollectionProxy(PBKey brokerKey, Query query, Class collectionClass)
{
Object args[] = {brokerKey, collectionClass, query};
try
{
return (ManageableCollection) getCollectionProxyConstructor(collectionClass).newInstance(args);
}
catch(InstantiationException ex)
{
throw new PersistenceBrokerException("Exception while creating a new collection proxy instance", ex);
}
catch(InvocationTargetException ex)
{
throw new PersistenceBrokerException("Exception while creating a new collection proxy instance", ex);
}
catch(IllegalAccessException ex)
{
throw new PersistenceBrokerException("Exception while creating a new collection proxy instance", ex);
}
} | java | public ManageableCollection createCollectionProxy(PBKey brokerKey, Query query, Class collectionClass)
{
Object args[] = {brokerKey, collectionClass, query};
try
{
return (ManageableCollection) getCollectionProxyConstructor(collectionClass).newInstance(args);
}
catch(InstantiationException ex)
{
throw new PersistenceBrokerException("Exception while creating a new collection proxy instance", ex);
}
catch(InvocationTargetException ex)
{
throw new PersistenceBrokerException("Exception while creating a new collection proxy instance", ex);
}
catch(IllegalAccessException ex)
{
throw new PersistenceBrokerException("Exception while creating a new collection proxy instance", ex);
}
} | [
"public",
"ManageableCollection",
"createCollectionProxy",
"(",
"PBKey",
"brokerKey",
",",
"Query",
"query",
",",
"Class",
"collectionClass",
")",
"{",
"Object",
"args",
"[",
"]",
"=",
"{",
"brokerKey",
",",
"collectionClass",
",",
"query",
"}",
";",
"try",
"{",
"return",
"(",
"ManageableCollection",
")",
"getCollectionProxyConstructor",
"(",
"collectionClass",
")",
".",
"newInstance",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Exception while creating a new collection proxy instance\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Exception while creating a new collection proxy instance\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Exception while creating a new collection proxy instance\"",
",",
"ex",
")",
";",
"}",
"}"
] | Create a Collection Proxy for a given query.
@param brokerKey The key of the persistence broker
@param query The query
@param collectionClass The class to build the proxy for
@return The collection proxy | [
"Create",
"a",
"Collection",
"Proxy",
"for",
"a",
"given",
"query",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L360-L380 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.getRealObject | public final Object getRealObject(Object objectOrProxy)
{
if(isNormalOjbProxy(objectOrProxy))
{
String msg;
try
{
return getIndirectionHandler(objectOrProxy).getRealSubject();
}
catch(ClassCastException e)
{
// shouldn't happen but still ...
msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(IllegalArgumentException e)
{
msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
throw e;
}
}
else if(isVirtualOjbProxy(objectOrProxy))
{
try
{
return ((VirtualProxy) objectOrProxy).getRealSubject();
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
throw e;
}
}
else
{
return objectOrProxy;
}
} | java | public final Object getRealObject(Object objectOrProxy)
{
if(isNormalOjbProxy(objectOrProxy))
{
String msg;
try
{
return getIndirectionHandler(objectOrProxy).getRealSubject();
}
catch(ClassCastException e)
{
// shouldn't happen but still ...
msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(IllegalArgumentException e)
{
msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
throw e;
}
}
else if(isVirtualOjbProxy(objectOrProxy))
{
try
{
return ((VirtualProxy) objectOrProxy).getRealSubject();
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
throw e;
}
}
else
{
return objectOrProxy;
}
} | [
"public",
"final",
"Object",
"getRealObject",
"(",
"Object",
"objectOrProxy",
")",
"{",
"if",
"(",
"isNormalOjbProxy",
"(",
"objectOrProxy",
")",
")",
"{",
"String",
"msg",
";",
"try",
"{",
"return",
"getIndirectionHandler",
"(",
"objectOrProxy",
")",
".",
"getRealSubject",
"(",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"// shouldn't happen but still ...\r",
"msg",
"=",
"\"The InvocationHandler for the provided Proxy was not an instance of \"",
"+",
"IndirectionHandler",
".",
"class",
".",
"getName",
"(",
")",
";",
"log",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"msg",
"=",
"\"Could not retrieve real object for given Proxy: \"",
"+",
"objectOrProxy",
";",
"log",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not retrieve real object for given Proxy: \"",
"+",
"objectOrProxy",
")",
";",
"throw",
"e",
";",
"}",
"}",
"else",
"if",
"(",
"isVirtualOjbProxy",
"(",
"objectOrProxy",
")",
")",
"{",
"try",
"{",
"return",
"(",
"(",
"VirtualProxy",
")",
"objectOrProxy",
")",
".",
"getRealSubject",
"(",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not retrieve real object for VirtualProxy: \"",
"+",
"objectOrProxy",
")",
";",
"throw",
"e",
";",
"}",
"}",
"else",
"{",
"return",
"objectOrProxy",
";",
"}",
"}"
] | Get the real Object
@param objectOrProxy
@return Object | [
"Get",
"the",
"real",
"Object"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L388-L433 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.getRealObjectIfMaterialized | public Object getRealObjectIfMaterialized(Object objectOrProxy)
{
if(isNormalOjbProxy(objectOrProxy))
{
String msg;
try
{
IndirectionHandler handler = getIndirectionHandler(objectOrProxy);
return handler.alreadyMaterialized() ? handler.getRealSubject() : null;
}
catch(ClassCastException e)
{
// shouldn't happen but still ...
msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(IllegalArgumentException e)
{
msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
throw e;
}
}
else if(isVirtualOjbProxy(objectOrProxy))
{
try
{
VirtualProxy proxy = (VirtualProxy) objectOrProxy;
return proxy.alreadyMaterialized() ? proxy.getRealSubject() : null;
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
throw e;
}
}
else
{
return objectOrProxy;
}
} | java | public Object getRealObjectIfMaterialized(Object objectOrProxy)
{
if(isNormalOjbProxy(objectOrProxy))
{
String msg;
try
{
IndirectionHandler handler = getIndirectionHandler(objectOrProxy);
return handler.alreadyMaterialized() ? handler.getRealSubject() : null;
}
catch(ClassCastException e)
{
// shouldn't happen but still ...
msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(IllegalArgumentException e)
{
msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
throw e;
}
}
else if(isVirtualOjbProxy(objectOrProxy))
{
try
{
VirtualProxy proxy = (VirtualProxy) objectOrProxy;
return proxy.alreadyMaterialized() ? proxy.getRealSubject() : null;
}
catch(PersistenceBrokerException e)
{
log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
throw e;
}
}
else
{
return objectOrProxy;
}
} | [
"public",
"Object",
"getRealObjectIfMaterialized",
"(",
"Object",
"objectOrProxy",
")",
"{",
"if",
"(",
"isNormalOjbProxy",
"(",
"objectOrProxy",
")",
")",
"{",
"String",
"msg",
";",
"try",
"{",
"IndirectionHandler",
"handler",
"=",
"getIndirectionHandler",
"(",
"objectOrProxy",
")",
";",
"return",
"handler",
".",
"alreadyMaterialized",
"(",
")",
"?",
"handler",
".",
"getRealSubject",
"(",
")",
":",
"null",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"// shouldn't happen but still ...\r",
"msg",
"=",
"\"The InvocationHandler for the provided Proxy was not an instance of \"",
"+",
"IndirectionHandler",
".",
"class",
".",
"getName",
"(",
")",
";",
"log",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"msg",
"=",
"\"Could not retrieve real object for given Proxy: \"",
"+",
"objectOrProxy",
";",
"log",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not retrieve real object for given Proxy: \"",
"+",
"objectOrProxy",
")",
";",
"throw",
"e",
";",
"}",
"}",
"else",
"if",
"(",
"isVirtualOjbProxy",
"(",
"objectOrProxy",
")",
")",
"{",
"try",
"{",
"VirtualProxy",
"proxy",
"=",
"(",
"VirtualProxy",
")",
"objectOrProxy",
";",
"return",
"proxy",
".",
"alreadyMaterialized",
"(",
")",
"?",
"proxy",
".",
"getRealSubject",
"(",
")",
":",
"null",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not retrieve real object for VirtualProxy: \"",
"+",
"objectOrProxy",
")",
";",
"throw",
"e",
";",
"}",
"}",
"else",
"{",
"return",
"objectOrProxy",
";",
"}",
"}"
] | Get the real Object for already materialized Handler
@param objectOrProxy
@return Object or null if the Handel is not materialized | [
"Get",
"the",
"real",
"Object",
"for",
"already",
"materialized",
"Handler"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L441-L490 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.getRealClass | public Class getRealClass(Object objectOrProxy)
{
IndirectionHandler handler;
if(isNormalOjbProxy(objectOrProxy))
{
String msg;
try
{
handler = getIndirectionHandler(objectOrProxy);
/*
arminw:
think we should return the real class
*/
// return handler.getIdentity().getObjectsTopLevelClass();
return handler.getIdentity().getObjectsRealClass();
}
catch(ClassCastException e)
{
// shouldn't happen but still ...
msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(IllegalArgumentException e)
{
msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
}
else if(isVirtualOjbProxy(objectOrProxy))
{
handler = VirtualProxy.getIndirectionHandler((VirtualProxy) objectOrProxy);
/*
arminw:
think we should return the real class
*/
// return handler.getIdentity().getObjectsTopLevelClass();
return handler.getIdentity().getObjectsRealClass();
}
else
{
return objectOrProxy.getClass();
}
} | java | public Class getRealClass(Object objectOrProxy)
{
IndirectionHandler handler;
if(isNormalOjbProxy(objectOrProxy))
{
String msg;
try
{
handler = getIndirectionHandler(objectOrProxy);
/*
arminw:
think we should return the real class
*/
// return handler.getIdentity().getObjectsTopLevelClass();
return handler.getIdentity().getObjectsRealClass();
}
catch(ClassCastException e)
{
// shouldn't happen but still ...
msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
catch(IllegalArgumentException e)
{
msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
log.error(msg);
throw new PersistenceBrokerException(msg, e);
}
}
else if(isVirtualOjbProxy(objectOrProxy))
{
handler = VirtualProxy.getIndirectionHandler((VirtualProxy) objectOrProxy);
/*
arminw:
think we should return the real class
*/
// return handler.getIdentity().getObjectsTopLevelClass();
return handler.getIdentity().getObjectsRealClass();
}
else
{
return objectOrProxy.getClass();
}
} | [
"public",
"Class",
"getRealClass",
"(",
"Object",
"objectOrProxy",
")",
"{",
"IndirectionHandler",
"handler",
";",
"if",
"(",
"isNormalOjbProxy",
"(",
"objectOrProxy",
")",
")",
"{",
"String",
"msg",
";",
"try",
"{",
"handler",
"=",
"getIndirectionHandler",
"(",
"objectOrProxy",
")",
";",
"/*\r\n arminw:\r\n think we should return the real class\r\n */",
"// return handler.getIdentity().getObjectsTopLevelClass();\r",
"return",
"handler",
".",
"getIdentity",
"(",
")",
".",
"getObjectsRealClass",
"(",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"// shouldn't happen but still ...\r",
"msg",
"=",
"\"The InvocationHandler for the provided Proxy was not an instance of \"",
"+",
"IndirectionHandler",
".",
"class",
".",
"getName",
"(",
")",
";",
"log",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"msg",
"=",
"\"Could not retrieve real object for given Proxy: \"",
"+",
"objectOrProxy",
";",
"log",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"isVirtualOjbProxy",
"(",
"objectOrProxy",
")",
")",
"{",
"handler",
"=",
"VirtualProxy",
".",
"getIndirectionHandler",
"(",
"(",
"VirtualProxy",
")",
"objectOrProxy",
")",
";",
"/*\r\n arminw:\r\n think we should return the real class\r\n */",
"// return handler.getIdentity().getObjectsTopLevelClass();\r",
"return",
"handler",
".",
"getIdentity",
"(",
")",
".",
"getObjectsRealClass",
"(",
")",
";",
"}",
"else",
"{",
"return",
"objectOrProxy",
".",
"getClass",
"(",
")",
";",
"}",
"}"
] | Get the real Class
@param objectOrProxy
@return Class | [
"Get",
"the",
"real",
"Class"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L498-L544 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.getIndirectionHandler | public IndirectionHandler getIndirectionHandler(Object obj)
{
if(obj == null)
{
return null;
}
else if(isNormalOjbProxy(obj))
{
return getDynamicIndirectionHandler(obj);
}
else if(isVirtualOjbProxy(obj))
{
return VirtualProxy.getIndirectionHandler((VirtualProxy) obj);
}
else
{
return null;
}
} | java | public IndirectionHandler getIndirectionHandler(Object obj)
{
if(obj == null)
{
return null;
}
else if(isNormalOjbProxy(obj))
{
return getDynamicIndirectionHandler(obj);
}
else if(isVirtualOjbProxy(obj))
{
return VirtualProxy.getIndirectionHandler((VirtualProxy) obj);
}
else
{
return null;
}
} | [
"public",
"IndirectionHandler",
"getIndirectionHandler",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"isNormalOjbProxy",
"(",
"obj",
")",
")",
"{",
"return",
"getDynamicIndirectionHandler",
"(",
"obj",
")",
";",
"}",
"else",
"if",
"(",
"isVirtualOjbProxy",
"(",
"obj",
")",
")",
"{",
"return",
"VirtualProxy",
".",
"getIndirectionHandler",
"(",
"(",
"VirtualProxy",
")",
"obj",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns the invocation handler object of the given proxy object.
@param obj The object
@return The invocation handler if the object is an OJB proxy, or <code>null</code>
otherwise | [
"Returns",
"the",
"invocation",
"handler",
"object",
"of",
"the",
"given",
"proxy",
"object",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L588-L607 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.isMaterialized | public boolean isMaterialized(Object object)
{
IndirectionHandler handler = getIndirectionHandler(object);
return handler == null || handler.alreadyMaterialized();
} | java | public boolean isMaterialized(Object object)
{
IndirectionHandler handler = getIndirectionHandler(object);
return handler == null || handler.alreadyMaterialized();
} | [
"public",
"boolean",
"isMaterialized",
"(",
"Object",
"object",
")",
"{",
"IndirectionHandler",
"handler",
"=",
"getIndirectionHandler",
"(",
"object",
")",
";",
"return",
"handler",
"==",
"null",
"||",
"handler",
".",
"alreadyMaterialized",
"(",
")",
";",
"}"
] | Determines whether the object is a materialized object, i.e. no proxy or a
proxy that has already been loaded from the database.
@param object The object to test
@return <code>true</code> if the object is materialized | [
"Determines",
"whether",
"the",
"object",
"is",
"a",
"materialized",
"object",
"i",
".",
"e",
".",
"no",
"proxy",
"or",
"a",
"proxy",
"that",
"has",
"already",
"been",
"loaded",
"from",
"the",
"database",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L616-L621 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java | OrganizationHandler.getOrganization | public DbOrganization getOrganization(final String organizationId) {
final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId);
if(dbOrganization == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Organization " + organizationId + " does not exist.").build());
}
return dbOrganization;
} | java | public DbOrganization getOrganization(final String organizationId) {
final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId);
if(dbOrganization == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Organization " + organizationId + " does not exist.").build());
}
return dbOrganization;
} | [
"public",
"DbOrganization",
"getOrganization",
"(",
"final",
"String",
"organizationId",
")",
"{",
"final",
"DbOrganization",
"dbOrganization",
"=",
"repositoryHandler",
".",
"getOrganization",
"(",
"organizationId",
")",
";",
"if",
"(",
"dbOrganization",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
".",
"entity",
"(",
"\"Organization \"",
"+",
"organizationId",
"+",
"\" does not exist.\"",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"return",
"dbOrganization",
";",
"}"
] | Returns an Organization
@param organizationId String
@return DbOrganization | [
"Returns",
"an",
"Organization"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java#L51-L60 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java | OrganizationHandler.deleteOrganization | public void deleteOrganization(final String organizationId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
repositoryHandler.deleteOrganization(dbOrganization.getName());
repositoryHandler.removeModulesOrganization(dbOrganization);
} | java | public void deleteOrganization(final String organizationId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
repositoryHandler.deleteOrganization(dbOrganization.getName());
repositoryHandler.removeModulesOrganization(dbOrganization);
} | [
"public",
"void",
"deleteOrganization",
"(",
"final",
"String",
"organizationId",
")",
"{",
"final",
"DbOrganization",
"dbOrganization",
"=",
"getOrganization",
"(",
"organizationId",
")",
";",
"repositoryHandler",
".",
"deleteOrganization",
"(",
"dbOrganization",
".",
"getName",
"(",
")",
")",
";",
"repositoryHandler",
".",
"removeModulesOrganization",
"(",
"dbOrganization",
")",
";",
"}"
] | Deletes an organization
@param organizationId String | [
"Deletes",
"an",
"organization"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java#L67-L71 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java | OrganizationHandler.getCorporateGroupIds | public List<String> getCorporateGroupIds(final String organizationId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
return dbOrganization.getCorporateGroupIdPrefixes();
} | java | public List<String> getCorporateGroupIds(final String organizationId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
return dbOrganization.getCorporateGroupIdPrefixes();
} | [
"public",
"List",
"<",
"String",
">",
"getCorporateGroupIds",
"(",
"final",
"String",
"organizationId",
")",
"{",
"final",
"DbOrganization",
"dbOrganization",
"=",
"getOrganization",
"(",
"organizationId",
")",
";",
"return",
"dbOrganization",
".",
"getCorporateGroupIdPrefixes",
"(",
")",
";",
"}"
] | Returns the list view of corporate groupIds of an organization
@param organizationId String
@return ListView | [
"Returns",
"the",
"list",
"view",
"of",
"corporate",
"groupIds",
"of",
"an",
"organization"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java#L79-L82 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java | OrganizationHandler.addCorporateGroupId | public void addCorporateGroupId(final String organizationId, final String corporateGroupId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
if(!dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){
dbOrganization.getCorporateGroupIdPrefixes().add(corporateGroupId);
repositoryHandler.store(dbOrganization);
}
repositoryHandler.addModulesOrganization(corporateGroupId, dbOrganization);
} | java | public void addCorporateGroupId(final String organizationId, final String corporateGroupId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
if(!dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){
dbOrganization.getCorporateGroupIdPrefixes().add(corporateGroupId);
repositoryHandler.store(dbOrganization);
}
repositoryHandler.addModulesOrganization(corporateGroupId, dbOrganization);
} | [
"public",
"void",
"addCorporateGroupId",
"(",
"final",
"String",
"organizationId",
",",
"final",
"String",
"corporateGroupId",
")",
"{",
"final",
"DbOrganization",
"dbOrganization",
"=",
"getOrganization",
"(",
"organizationId",
")",
";",
"if",
"(",
"!",
"dbOrganization",
".",
"getCorporateGroupIdPrefixes",
"(",
")",
".",
"contains",
"(",
"corporateGroupId",
")",
")",
"{",
"dbOrganization",
".",
"getCorporateGroupIdPrefixes",
"(",
")",
".",
"add",
"(",
"corporateGroupId",
")",
";",
"repositoryHandler",
".",
"store",
"(",
"dbOrganization",
")",
";",
"}",
"repositoryHandler",
".",
"addModulesOrganization",
"(",
"corporateGroupId",
",",
"dbOrganization",
")",
";",
"}"
] | Adds a corporate groupId to an organization
@param organizationId String
@param corporateGroupId String | [
"Adds",
"a",
"corporate",
"groupId",
"to",
"an",
"organization"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java#L90-L99 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java | OrganizationHandler.removeCorporateGroupId | public void removeCorporateGroupId(final String organizationId, final String corporateGroupId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){
dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId);
repositoryHandler.store(dbOrganization);
}
repositoryHandler.removeModulesOrganization(corporateGroupId, dbOrganization);
} | java | public void removeCorporateGroupId(final String organizationId, final String corporateGroupId) {
final DbOrganization dbOrganization = getOrganization(organizationId);
if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){
dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId);
repositoryHandler.store(dbOrganization);
}
repositoryHandler.removeModulesOrganization(corporateGroupId, dbOrganization);
} | [
"public",
"void",
"removeCorporateGroupId",
"(",
"final",
"String",
"organizationId",
",",
"final",
"String",
"corporateGroupId",
")",
"{",
"final",
"DbOrganization",
"dbOrganization",
"=",
"getOrganization",
"(",
"organizationId",
")",
";",
"if",
"(",
"dbOrganization",
".",
"getCorporateGroupIdPrefixes",
"(",
")",
".",
"contains",
"(",
"corporateGroupId",
")",
")",
"{",
"dbOrganization",
".",
"getCorporateGroupIdPrefixes",
"(",
")",
".",
"remove",
"(",
"corporateGroupId",
")",
";",
"repositoryHandler",
".",
"store",
"(",
"dbOrganization",
")",
";",
"}",
"repositoryHandler",
".",
"removeModulesOrganization",
"(",
"corporateGroupId",
",",
"dbOrganization",
")",
";",
"}"
] | Removes a corporate groupId from an Organisation
@param organizationId String
@param corporateGroupId String | [
"Removes",
"a",
"corporate",
"groupId",
"from",
"an",
"Organisation"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java#L107-L116 | train |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java | OrganizationHandler.getMatchingOrganization | public DbOrganization getMatchingOrganization(final DbModule dbModule) {
if(dbModule.getOrganization() != null
&& !dbModule.getOrganization().isEmpty()){
return getOrganization(dbModule.getOrganization());
}
for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){
final CorporateFilter corporateFilter = new CorporateFilter(organization);
if(corporateFilter.matches(dbModule)){
return organization;
}
}
return null;
} | java | public DbOrganization getMatchingOrganization(final DbModule dbModule) {
if(dbModule.getOrganization() != null
&& !dbModule.getOrganization().isEmpty()){
return getOrganization(dbModule.getOrganization());
}
for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){
final CorporateFilter corporateFilter = new CorporateFilter(organization);
if(corporateFilter.matches(dbModule)){
return organization;
}
}
return null;
} | [
"public",
"DbOrganization",
"getMatchingOrganization",
"(",
"final",
"DbModule",
"dbModule",
")",
"{",
"if",
"(",
"dbModule",
".",
"getOrganization",
"(",
")",
"!=",
"null",
"&&",
"!",
"dbModule",
".",
"getOrganization",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"getOrganization",
"(",
"dbModule",
".",
"getOrganization",
"(",
")",
")",
";",
"}",
"for",
"(",
"final",
"DbOrganization",
"organization",
":",
"repositoryHandler",
".",
"getAllOrganizations",
"(",
")",
")",
"{",
"final",
"CorporateFilter",
"corporateFilter",
"=",
"new",
"CorporateFilter",
"(",
"organization",
")",
";",
"if",
"(",
"corporateFilter",
".",
"matches",
"(",
"dbModule",
")",
")",
"{",
"return",
"organization",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns an Organization that suits the Module or null if there is none
@param dbModule DbModule
@return DbOrganization | [
"Returns",
"an",
"Organization",
"that",
"suits",
"the",
"Module",
"or",
"null",
"if",
"there",
"is",
"none"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/OrganizationHandler.java#L125-L139 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.executeDelete | public void executeDelete(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeDelete: " + obj);
}
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
try
{
stmt = sm.getDeleteStatement(cld);
if (stmt == null)
{
logger.error("getDeleteStatement returned a null statement");
throw new PersistenceBrokerException("JdbcAccessImpl: getDeleteStatement returned a null statement");
}
sm.bindDelete(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeDelete: " + stmt);
// @todo: clearify semantics
// thma: the following check is not secure. The object could be deleted *or* changed.
// if it was deleted it makes no sense to throw an OL exception.
// does is make sense to throw an OL exception if the object was changed?
if (stmt.executeUpdate() == 0 && cld.isLocking()) //BRJ
{
/**
* Kuali Foundation modification -- 6/19/2009
*/
String objToString = "";
try {
objToString = obj.toString();
} catch (Exception ex) {}
throw new OptimisticLockException("Object has been modified or deleted by someone else: " + objToString, obj);
/**
* End of Kuali Foundation modification
*/
}
// Harvest any return values.
harvestReturnValues(cld.getDeleteProcedure(), obj, stmt);
}
catch (OptimisticLockException e)
{
// Don't log as error
if (logger.isDebugEnabled())
logger.debug("OptimisticLockException during the execution of delete: "
+ e.getMessage(), e);
throw e;
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of delete: "
+ e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedDeleteStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);
}
finally
{
sm.closeResources(stmt, null);
}
} | java | public void executeDelete(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeDelete: " + obj);
}
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
try
{
stmt = sm.getDeleteStatement(cld);
if (stmt == null)
{
logger.error("getDeleteStatement returned a null statement");
throw new PersistenceBrokerException("JdbcAccessImpl: getDeleteStatement returned a null statement");
}
sm.bindDelete(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeDelete: " + stmt);
// @todo: clearify semantics
// thma: the following check is not secure. The object could be deleted *or* changed.
// if it was deleted it makes no sense to throw an OL exception.
// does is make sense to throw an OL exception if the object was changed?
if (stmt.executeUpdate() == 0 && cld.isLocking()) //BRJ
{
/**
* Kuali Foundation modification -- 6/19/2009
*/
String objToString = "";
try {
objToString = obj.toString();
} catch (Exception ex) {}
throw new OptimisticLockException("Object has been modified or deleted by someone else: " + objToString, obj);
/**
* End of Kuali Foundation modification
*/
}
// Harvest any return values.
harvestReturnValues(cld.getDeleteProcedure(), obj, stmt);
}
catch (OptimisticLockException e)
{
// Don't log as error
if (logger.isDebugEnabled())
logger.debug("OptimisticLockException during the execution of delete: "
+ e.getMessage(), e);
throw e;
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of delete: "
+ e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedDeleteStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);
}
finally
{
sm.closeResources(stmt, null);
}
} | [
"public",
"void",
"executeDelete",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"obj",
")",
"throws",
"PersistenceBrokerException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"executeDelete: \"",
"+",
"obj",
")",
";",
"}",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"try",
"{",
"stmt",
"=",
"sm",
".",
"getDeleteStatement",
"(",
"cld",
")",
";",
"if",
"(",
"stmt",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"getDeleteStatement returned a null statement\"",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"JdbcAccessImpl: getDeleteStatement returned a null statement\"",
")",
";",
"}",
"sm",
".",
"bindDelete",
"(",
"stmt",
",",
"cld",
",",
"obj",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeDelete: \"",
"+",
"stmt",
")",
";",
"// @todo: clearify semantics\r",
"// thma: the following check is not secure. The object could be deleted *or* changed.\r",
"// if it was deleted it makes no sense to throw an OL exception.\r",
"// does is make sense to throw an OL exception if the object was changed?\r",
"if",
"(",
"stmt",
".",
"executeUpdate",
"(",
")",
"==",
"0",
"&&",
"cld",
".",
"isLocking",
"(",
")",
")",
"//BRJ\r",
"{",
"/**\r\n * Kuali Foundation modification -- 6/19/2009\r\n */",
"String",
"objToString",
"=",
"\"\"",
";",
"try",
"{",
"objToString",
"=",
"obj",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"throw",
"new",
"OptimisticLockException",
"(",
"\"Object has been modified or deleted by someone else: \"",
"+",
"objToString",
",",
"obj",
")",
";",
"/**\r\n * End of Kuali Foundation modification\r\n */",
"}",
"// Harvest any return values.\r",
"harvestReturnValues",
"(",
"cld",
".",
"getDeleteProcedure",
"(",
")",
",",
"obj",
",",
"stmt",
")",
";",
"}",
"catch",
"(",
"OptimisticLockException",
"e",
")",
"{",
"// Don't log as error\r",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"OptimisticLockException during the execution of delete: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of delete: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"final",
"String",
"sql",
"=",
"broker",
".",
"serviceSqlGenerator",
"(",
")",
".",
"getPreparedDeleteStatement",
"(",
"cld",
")",
".",
"getStatement",
"(",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sql",
",",
"cld",
",",
"logger",
",",
"obj",
")",
";",
"}",
"finally",
"{",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"null",
")",
";",
"}",
"}"
] | performs a DELETE operation against RDBMS.
@param cld ClassDescriptor providing mapping information.
@param obj The object to be deleted. | [
"performs",
"a",
"DELETE",
"operation",
"against",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L91-L158 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.executeInsert | public void executeInsert(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeInsert: " + obj);
}
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
try
{
stmt = sm.getInsertStatement(cld);
if (stmt == null)
{
logger.error("getInsertStatement returned a null statement");
throw new PersistenceBrokerException("getInsertStatement returned a null statement");
}
// before bind values perform autoincrement sequence columns
assignAutoincrementSequences(cld, obj);
sm.bindInsert(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeInsert: " + stmt);
stmt.executeUpdate();
// after insert read and assign identity columns
assignAutoincrementIdentityColumns(cld, obj);
// Harvest any return values.
harvestReturnValues(cld.getInsertProcedure(), obj, stmt);
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of the insert: " + e.getMessage(), e);
throw e;
}
catch(SequenceManagerException e)
{
throw new PersistenceBrokerException("Error while try to assign identity value", e);
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedInsertStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);
}
finally
{
sm.closeResources(stmt, null);
}
} | java | public void executeInsert(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeInsert: " + obj);
}
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
try
{
stmt = sm.getInsertStatement(cld);
if (stmt == null)
{
logger.error("getInsertStatement returned a null statement");
throw new PersistenceBrokerException("getInsertStatement returned a null statement");
}
// before bind values perform autoincrement sequence columns
assignAutoincrementSequences(cld, obj);
sm.bindInsert(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeInsert: " + stmt);
stmt.executeUpdate();
// after insert read and assign identity columns
assignAutoincrementIdentityColumns(cld, obj);
// Harvest any return values.
harvestReturnValues(cld.getInsertProcedure(), obj, stmt);
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of the insert: " + e.getMessage(), e);
throw e;
}
catch(SequenceManagerException e)
{
throw new PersistenceBrokerException("Error while try to assign identity value", e);
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedInsertStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);
}
finally
{
sm.closeResources(stmt, null);
}
} | [
"public",
"void",
"executeInsert",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"obj",
")",
"throws",
"PersistenceBrokerException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"executeInsert: \"",
"+",
"obj",
")",
";",
"}",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"try",
"{",
"stmt",
"=",
"sm",
".",
"getInsertStatement",
"(",
"cld",
")",
";",
"if",
"(",
"stmt",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"getInsertStatement returned a null statement\"",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"getInsertStatement returned a null statement\"",
")",
";",
"}",
"// before bind values perform autoincrement sequence columns\r",
"assignAutoincrementSequences",
"(",
"cld",
",",
"obj",
")",
";",
"sm",
".",
"bindInsert",
"(",
"stmt",
",",
"cld",
",",
"obj",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeInsert: \"",
"+",
"stmt",
")",
";",
"stmt",
".",
"executeUpdate",
"(",
")",
";",
"// after insert read and assign identity columns\r",
"assignAutoincrementIdentityColumns",
"(",
"cld",
",",
"obj",
")",
";",
"// Harvest any return values.\r",
"harvestReturnValues",
"(",
"cld",
".",
"getInsertProcedure",
"(",
")",
",",
"obj",
",",
"stmt",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of the insert: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SequenceManagerException",
"e",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Error while try to assign identity value\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"final",
"String",
"sql",
"=",
"broker",
".",
"serviceSqlGenerator",
"(",
")",
".",
"getPreparedInsertStatement",
"(",
"cld",
")",
".",
"getStatement",
"(",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sql",
",",
"cld",
",",
"logger",
",",
"obj",
")",
";",
"}",
"finally",
"{",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"null",
")",
";",
"}",
"}"
] | performs an INSERT operation against RDBMS.
@param obj The Object to be inserted as a row of the underlying table.
@param cld ClassDescriptor providing mapping information. | [
"performs",
"an",
"INSERT",
"operation",
"against",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L200-L246 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.executeQuery | public ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeQuery: " + query);
}
/*
* MBAIRD: we should create a scrollable resultset if the start at
* index or end at index is set
*/
boolean scrollable = ((query.getStartAtIndex() > Query.NO_START_AT_INDEX) || (query.getEndAtIndex() > Query.NO_END_AT_INDEX));
/*
* OR if the prefetching of relationships is being used.
*/
if (query != null && query.getPrefetchedRelationships() != null && !query.getPrefetchedRelationships().isEmpty())
{
scrollable = true;
}
final StatementManagerIF sm = broker.serviceStatementManager();
final SelectStatement sql = broker.serviceSqlGenerator().getPreparedSelectStatement(query, cld);
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
final int queryFetchSize = query.getFetchSize();
final boolean isStoredProcedure = isStoredProcedure(sql.getStatement());
stmt = sm.getPreparedStatement(cld, sql.getStatement() ,
scrollable, queryFetchSize, isStoredProcedure);
if (isStoredProcedure)
{
// Query implemented as a stored procedure, which must return a result set.
// Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}
getPlatform().registerOutResultSet((CallableStatement) stmt, 1);
sm.bindStatement(stmt, query, cld, 2);
if (logger.isDebugEnabled())
logger.debug("executeQuery: " + stmt);
stmt.execute();
rs = (ResultSet) ((CallableStatement) stmt).getObject(1);
}
else
{
sm.bindStatement(stmt, query, cld, 1);
if (logger.isDebugEnabled())
logger.debug("executeQuery: " + stmt);
rs = stmt.executeQuery();
}
return new ResultSetAndStatement(sm, stmt, rs, sql);
}
catch (PersistenceBrokerException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
logger.error("PersistenceBrokerException during the execution of the query: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
throw ExceptionHelper.generateException(e, sql.getStatement(), null, logger, null);
}
} | java | public ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeQuery: " + query);
}
/*
* MBAIRD: we should create a scrollable resultset if the start at
* index or end at index is set
*/
boolean scrollable = ((query.getStartAtIndex() > Query.NO_START_AT_INDEX) || (query.getEndAtIndex() > Query.NO_END_AT_INDEX));
/*
* OR if the prefetching of relationships is being used.
*/
if (query != null && query.getPrefetchedRelationships() != null && !query.getPrefetchedRelationships().isEmpty())
{
scrollable = true;
}
final StatementManagerIF sm = broker.serviceStatementManager();
final SelectStatement sql = broker.serviceSqlGenerator().getPreparedSelectStatement(query, cld);
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
final int queryFetchSize = query.getFetchSize();
final boolean isStoredProcedure = isStoredProcedure(sql.getStatement());
stmt = sm.getPreparedStatement(cld, sql.getStatement() ,
scrollable, queryFetchSize, isStoredProcedure);
if (isStoredProcedure)
{
// Query implemented as a stored procedure, which must return a result set.
// Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}
getPlatform().registerOutResultSet((CallableStatement) stmt, 1);
sm.bindStatement(stmt, query, cld, 2);
if (logger.isDebugEnabled())
logger.debug("executeQuery: " + stmt);
stmt.execute();
rs = (ResultSet) ((CallableStatement) stmt).getObject(1);
}
else
{
sm.bindStatement(stmt, query, cld, 1);
if (logger.isDebugEnabled())
logger.debug("executeQuery: " + stmt);
rs = stmt.executeQuery();
}
return new ResultSetAndStatement(sm, stmt, rs, sql);
}
catch (PersistenceBrokerException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
logger.error("PersistenceBrokerException during the execution of the query: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
throw ExceptionHelper.generateException(e, sql.getStatement(), null, logger, null);
}
} | [
"public",
"ResultSetAndStatement",
"executeQuery",
"(",
"Query",
"query",
",",
"ClassDescriptor",
"cld",
")",
"throws",
"PersistenceBrokerException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"executeQuery: \"",
"+",
"query",
")",
";",
"}",
"/*\r\n\t\t * MBAIRD: we should create a scrollable resultset if the start at\r\n\t\t * index or end at index is set\r\n\t\t */",
"boolean",
"scrollable",
"=",
"(",
"(",
"query",
".",
"getStartAtIndex",
"(",
")",
">",
"Query",
".",
"NO_START_AT_INDEX",
")",
"||",
"(",
"query",
".",
"getEndAtIndex",
"(",
")",
">",
"Query",
".",
"NO_END_AT_INDEX",
")",
")",
";",
"/*\r\n\t\t * OR if the prefetching of relationships is being used.\r\n\t\t */",
"if",
"(",
"query",
"!=",
"null",
"&&",
"query",
".",
"getPrefetchedRelationships",
"(",
")",
"!=",
"null",
"&&",
"!",
"query",
".",
"getPrefetchedRelationships",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"scrollable",
"=",
"true",
";",
"}",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"final",
"SelectStatement",
"sql",
"=",
"broker",
".",
"serviceSqlGenerator",
"(",
")",
".",
"getPreparedSelectStatement",
"(",
"query",
",",
"cld",
")",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"final",
"int",
"queryFetchSize",
"=",
"query",
".",
"getFetchSize",
"(",
")",
";",
"final",
"boolean",
"isStoredProcedure",
"=",
"isStoredProcedure",
"(",
"sql",
".",
"getStatement",
"(",
")",
")",
";",
"stmt",
"=",
"sm",
".",
"getPreparedStatement",
"(",
"cld",
",",
"sql",
".",
"getStatement",
"(",
")",
",",
"scrollable",
",",
"queryFetchSize",
",",
"isStoredProcedure",
")",
";",
"if",
"(",
"isStoredProcedure",
")",
"{",
"// Query implemented as a stored procedure, which must return a result set.\r",
"// Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}\r",
"getPlatform",
"(",
")",
".",
"registerOutResultSet",
"(",
"(",
"CallableStatement",
")",
"stmt",
",",
"1",
")",
";",
"sm",
".",
"bindStatement",
"(",
"stmt",
",",
"query",
",",
"cld",
",",
"2",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeQuery: \"",
"+",
"stmt",
")",
";",
"stmt",
".",
"execute",
"(",
")",
";",
"rs",
"=",
"(",
"ResultSet",
")",
"(",
"(",
"CallableStatement",
")",
"stmt",
")",
".",
"getObject",
"(",
"1",
")",
";",
"}",
"else",
"{",
"sm",
".",
"bindStatement",
"(",
"stmt",
",",
"query",
",",
"cld",
",",
"1",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeQuery: \"",
"+",
"stmt",
")",
";",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
")",
";",
"}",
"return",
"new",
"ResultSetAndStatement",
"(",
"sm",
",",
"stmt",
",",
"rs",
",",
"sql",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"// release resources on exception\r",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"rs",
")",
";",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of the query: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"// release resources on exception\r",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"rs",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sql",
".",
"getStatement",
"(",
")",
",",
"null",
",",
"logger",
",",
"null",
")",
";",
"}",
"}"
] | performs a SELECT operation against RDBMS.
@param query the query string.
@param cld ClassDescriptor providing JDBC information. | [
"performs",
"a",
"SELECT",
"operation",
"against",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L253-L319 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.executeSQL | public ResultSetAndStatement executeSQL(
final String sql,
ClassDescriptor cld,
ValueContainer[] values,
boolean scrollable)
throws PersistenceBrokerException
{
if (logger.isDebugEnabled()) logger.debug("executeSQL: " + sql);
final boolean isStoredprocedure = isStoredProcedure(sql);
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
stmt = sm.getPreparedStatement(cld, sql,
scrollable, StatementManagerIF.FETCH_SIZE_NOT_EXPLICITLY_SET, isStoredprocedure);
if (isStoredprocedure)
{
// Query implemented as a stored procedure, which must return a result set.
// Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}
getPlatform().registerOutResultSet((CallableStatement) stmt, 1);
sm.bindValues(stmt, values, 2);
stmt.execute();
rs = (ResultSet) ((CallableStatement) stmt).getObject(1);
}
else
{
sm.bindValues(stmt, values, 1);
rs = stmt.executeQuery();
}
// as we return the resultset for further operations, we cannot release the statement yet.
// that has to be done by the JdbcAccess-clients (i.e. RsIterator, ProxyRsIterator and PkEnumeration.)
return new ResultSetAndStatement(sm, stmt, rs, new SelectStatement()
{
public Query getQueryInstance()
{
return null;
}
public int getColumnIndex(FieldDescriptor fld)
{
return JdbcType.MIN_INT;
}
public String getStatement()
{
return sql;
}
});
}
catch (PersistenceBrokerException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
logger.error("PersistenceBrokerException during the execution of the SQL query: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
throw ExceptionHelper.generateException(e, sql, cld, values, logger, null);
}
} | java | public ResultSetAndStatement executeSQL(
final String sql,
ClassDescriptor cld,
ValueContainer[] values,
boolean scrollable)
throws PersistenceBrokerException
{
if (logger.isDebugEnabled()) logger.debug("executeSQL: " + sql);
final boolean isStoredprocedure = isStoredProcedure(sql);
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
stmt = sm.getPreparedStatement(cld, sql,
scrollable, StatementManagerIF.FETCH_SIZE_NOT_EXPLICITLY_SET, isStoredprocedure);
if (isStoredprocedure)
{
// Query implemented as a stored procedure, which must return a result set.
// Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}
getPlatform().registerOutResultSet((CallableStatement) stmt, 1);
sm.bindValues(stmt, values, 2);
stmt.execute();
rs = (ResultSet) ((CallableStatement) stmt).getObject(1);
}
else
{
sm.bindValues(stmt, values, 1);
rs = stmt.executeQuery();
}
// as we return the resultset for further operations, we cannot release the statement yet.
// that has to be done by the JdbcAccess-clients (i.e. RsIterator, ProxyRsIterator and PkEnumeration.)
return new ResultSetAndStatement(sm, stmt, rs, new SelectStatement()
{
public Query getQueryInstance()
{
return null;
}
public int getColumnIndex(FieldDescriptor fld)
{
return JdbcType.MIN_INT;
}
public String getStatement()
{
return sql;
}
});
}
catch (PersistenceBrokerException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
logger.error("PersistenceBrokerException during the execution of the SQL query: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
throw ExceptionHelper.generateException(e, sql, cld, values, logger, null);
}
} | [
"public",
"ResultSetAndStatement",
"executeSQL",
"(",
"final",
"String",
"sql",
",",
"ClassDescriptor",
"cld",
",",
"ValueContainer",
"[",
"]",
"values",
",",
"boolean",
"scrollable",
")",
"throws",
"PersistenceBrokerException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeSQL: \"",
"+",
"sql",
")",
";",
"final",
"boolean",
"isStoredprocedure",
"=",
"isStoredProcedure",
"(",
"sql",
")",
";",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"stmt",
"=",
"sm",
".",
"getPreparedStatement",
"(",
"cld",
",",
"sql",
",",
"scrollable",
",",
"StatementManagerIF",
".",
"FETCH_SIZE_NOT_EXPLICITLY_SET",
",",
"isStoredprocedure",
")",
";",
"if",
"(",
"isStoredprocedure",
")",
"{",
"// Query implemented as a stored procedure, which must return a result set.\r",
"// Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}\r",
"getPlatform",
"(",
")",
".",
"registerOutResultSet",
"(",
"(",
"CallableStatement",
")",
"stmt",
",",
"1",
")",
";",
"sm",
".",
"bindValues",
"(",
"stmt",
",",
"values",
",",
"2",
")",
";",
"stmt",
".",
"execute",
"(",
")",
";",
"rs",
"=",
"(",
"ResultSet",
")",
"(",
"(",
"CallableStatement",
")",
"stmt",
")",
".",
"getObject",
"(",
"1",
")",
";",
"}",
"else",
"{",
"sm",
".",
"bindValues",
"(",
"stmt",
",",
"values",
",",
"1",
")",
";",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
")",
";",
"}",
"// as we return the resultset for further operations, we cannot release the statement yet.\r",
"// that has to be done by the JdbcAccess-clients (i.e. RsIterator, ProxyRsIterator and PkEnumeration.)\r",
"return",
"new",
"ResultSetAndStatement",
"(",
"sm",
",",
"stmt",
",",
"rs",
",",
"new",
"SelectStatement",
"(",
")",
"{",
"public",
"Query",
"getQueryInstance",
"(",
")",
"{",
"return",
"null",
";",
"}",
"public",
"int",
"getColumnIndex",
"(",
"FieldDescriptor",
"fld",
")",
"{",
"return",
"JdbcType",
".",
"MIN_INT",
";",
"}",
"public",
"String",
"getStatement",
"(",
")",
"{",
"return",
"sql",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"// release resources on exception\r",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"rs",
")",
";",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of the SQL query: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"// release resources on exception\r",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"rs",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sql",
",",
"cld",
",",
"values",
",",
"logger",
",",
"null",
")",
";",
"}",
"}"
] | performs a SQL SELECT statement against RDBMS.
@param sql the query string.
@param cld ClassDescriptor providing meta-information. | [
"performs",
"a",
"SQL",
"SELECT",
"statement",
"against",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L335-L399 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.executeUpdateSQL | public int executeUpdateSQL(
String sqlStatement,
ClassDescriptor cld,
ValueContainer[] values1,
ValueContainer[] values2)
throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
logger.debug("executeUpdateSQL: " + sqlStatement);
int result;
int index;
PreparedStatement stmt = null;
final StatementManagerIF sm = broker.serviceStatementManager();
try
{
stmt = sm.getPreparedStatement(cld, sqlStatement,
Query.NOT_SCROLLABLE, StatementManagerIF.FETCH_SIZE_NOT_APPLICABLE, isStoredProcedure(sqlStatement));
index = sm.bindValues(stmt, values1, 1);
sm.bindValues(stmt, values2, index);
result = stmt.executeUpdate();
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of the Update SQL query: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
ValueContainer[] tmp = addValues(values1, values2);
throw ExceptionHelper.generateException(e, sqlStatement, cld, tmp, logger, null);
}
finally
{
sm.closeResources(stmt, null);
}
return result;
} | java | public int executeUpdateSQL(
String sqlStatement,
ClassDescriptor cld,
ValueContainer[] values1,
ValueContainer[] values2)
throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
logger.debug("executeUpdateSQL: " + sqlStatement);
int result;
int index;
PreparedStatement stmt = null;
final StatementManagerIF sm = broker.serviceStatementManager();
try
{
stmt = sm.getPreparedStatement(cld, sqlStatement,
Query.NOT_SCROLLABLE, StatementManagerIF.FETCH_SIZE_NOT_APPLICABLE, isStoredProcedure(sqlStatement));
index = sm.bindValues(stmt, values1, 1);
sm.bindValues(stmt, values2, index);
result = stmt.executeUpdate();
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of the Update SQL query: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
ValueContainer[] tmp = addValues(values1, values2);
throw ExceptionHelper.generateException(e, sqlStatement, cld, tmp, logger, null);
}
finally
{
sm.closeResources(stmt, null);
}
return result;
} | [
"public",
"int",
"executeUpdateSQL",
"(",
"String",
"sqlStatement",
",",
"ClassDescriptor",
"cld",
",",
"ValueContainer",
"[",
"]",
"values1",
",",
"ValueContainer",
"[",
"]",
"values2",
")",
"throws",
"PersistenceBrokerException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeUpdateSQL: \"",
"+",
"sqlStatement",
")",
";",
"int",
"result",
";",
"int",
"index",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"try",
"{",
"stmt",
"=",
"sm",
".",
"getPreparedStatement",
"(",
"cld",
",",
"sqlStatement",
",",
"Query",
".",
"NOT_SCROLLABLE",
",",
"StatementManagerIF",
".",
"FETCH_SIZE_NOT_APPLICABLE",
",",
"isStoredProcedure",
"(",
"sqlStatement",
")",
")",
";",
"index",
"=",
"sm",
".",
"bindValues",
"(",
"stmt",
",",
"values1",
",",
"1",
")",
";",
"sm",
".",
"bindValues",
"(",
"stmt",
",",
"values2",
",",
"index",
")",
";",
"result",
"=",
"stmt",
".",
"executeUpdate",
"(",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of the Update SQL query: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"ValueContainer",
"[",
"]",
"tmp",
"=",
"addValues",
"(",
"values1",
",",
"values2",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sqlStatement",
",",
"cld",
",",
"tmp",
",",
"logger",
",",
"null",
")",
";",
"}",
"finally",
"{",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"null",
")",
";",
"}",
"return",
"result",
";",
"}"
] | performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.
@param sqlStatement the query string.
@param cld ClassDescriptor providing meta-information.
@return int returncode | [
"performs",
"a",
"SQL",
"UPDTE",
"INSERT",
"or",
"DELETE",
"statement",
"against",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L413-L450 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.executeUpdate | public void executeUpdate(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeUpdate: " + obj);
}
// obj with nothing but key fields is not updated
if (cld.getNonPkRwFields().length == 0)
{
return;
}
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
// BRJ: preserve current locking values
// locking values will be restored in case of exception
ValueContainer[] oldLockingValues;
oldLockingValues = cld.getCurrentLockingValues(obj);
try
{
stmt = sm.getUpdateStatement(cld);
if (stmt == null)
{
logger.error("getUpdateStatement returned a null statement");
throw new PersistenceBrokerException("getUpdateStatement returned a null statement");
}
sm.bindUpdate(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeUpdate: " + stmt);
if ((stmt.executeUpdate() == 0) && cld.isLocking()) //BRJ
{
/**
* Kuali Foundation modification -- 6/19/2009
*/
String objToString = "";
try {
objToString = obj.toString();
} catch (Exception ex) {}
throw new OptimisticLockException("Object has been modified by someone else: " + objToString, obj);
/**
* End of Kuali Foundation modification
*/
}
// Harvest any return values.
harvestReturnValues(cld.getUpdateProcedure(), obj, stmt);
}
catch (OptimisticLockException e)
{
// Don't log as error
if (logger.isDebugEnabled())
logger.debug(
"OptimisticLockException during the execution of update: " + e.getMessage(),
e);
throw e;
}
catch (PersistenceBrokerException e)
{
// BRJ: restore old locking values
setLockingValues(cld, obj, oldLockingValues);
logger.error(
"PersistenceBrokerException during the execution of the update: " + e.getMessage(),
e);
throw e;
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedUpdateStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);
}
finally
{
sm.closeResources(stmt, null);
}
} | java | public void executeUpdate(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
{
if (logger.isDebugEnabled())
{
logger.debug("executeUpdate: " + obj);
}
// obj with nothing but key fields is not updated
if (cld.getNonPkRwFields().length == 0)
{
return;
}
final StatementManagerIF sm = broker.serviceStatementManager();
PreparedStatement stmt = null;
// BRJ: preserve current locking values
// locking values will be restored in case of exception
ValueContainer[] oldLockingValues;
oldLockingValues = cld.getCurrentLockingValues(obj);
try
{
stmt = sm.getUpdateStatement(cld);
if (stmt == null)
{
logger.error("getUpdateStatement returned a null statement");
throw new PersistenceBrokerException("getUpdateStatement returned a null statement");
}
sm.bindUpdate(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeUpdate: " + stmt);
if ((stmt.executeUpdate() == 0) && cld.isLocking()) //BRJ
{
/**
* Kuali Foundation modification -- 6/19/2009
*/
String objToString = "";
try {
objToString = obj.toString();
} catch (Exception ex) {}
throw new OptimisticLockException("Object has been modified by someone else: " + objToString, obj);
/**
* End of Kuali Foundation modification
*/
}
// Harvest any return values.
harvestReturnValues(cld.getUpdateProcedure(), obj, stmt);
}
catch (OptimisticLockException e)
{
// Don't log as error
if (logger.isDebugEnabled())
logger.debug(
"OptimisticLockException during the execution of update: " + e.getMessage(),
e);
throw e;
}
catch (PersistenceBrokerException e)
{
// BRJ: restore old locking values
setLockingValues(cld, obj, oldLockingValues);
logger.error(
"PersistenceBrokerException during the execution of the update: " + e.getMessage(),
e);
throw e;
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedUpdateStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);
}
finally
{
sm.closeResources(stmt, null);
}
} | [
"public",
"void",
"executeUpdate",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"obj",
")",
"throws",
"PersistenceBrokerException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"executeUpdate: \"",
"+",
"obj",
")",
";",
"}",
"// obj with nothing but key fields is not updated\r",
"if",
"(",
"cld",
".",
"getNonPkRwFields",
"(",
")",
".",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"// BRJ: preserve current locking values\r",
"// locking values will be restored in case of exception\r",
"ValueContainer",
"[",
"]",
"oldLockingValues",
";",
"oldLockingValues",
"=",
"cld",
".",
"getCurrentLockingValues",
"(",
"obj",
")",
";",
"try",
"{",
"stmt",
"=",
"sm",
".",
"getUpdateStatement",
"(",
"cld",
")",
";",
"if",
"(",
"stmt",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"getUpdateStatement returned a null statement\"",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"getUpdateStatement returned a null statement\"",
")",
";",
"}",
"sm",
".",
"bindUpdate",
"(",
"stmt",
",",
"cld",
",",
"obj",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"executeUpdate: \"",
"+",
"stmt",
")",
";",
"if",
"(",
"(",
"stmt",
".",
"executeUpdate",
"(",
")",
"==",
"0",
")",
"&&",
"cld",
".",
"isLocking",
"(",
")",
")",
"//BRJ\r",
"{",
"/**\r\n * Kuali Foundation modification -- 6/19/2009\r\n */",
"String",
"objToString",
"=",
"\"\"",
";",
"try",
"{",
"objToString",
"=",
"obj",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"throw",
"new",
"OptimisticLockException",
"(",
"\"Object has been modified by someone else: \"",
"+",
"objToString",
",",
"obj",
")",
";",
"/**\r\n * End of Kuali Foundation modification\r\n */",
"}",
"// Harvest any return values.\r",
"harvestReturnValues",
"(",
"cld",
".",
"getUpdateProcedure",
"(",
")",
",",
"obj",
",",
"stmt",
")",
";",
"}",
"catch",
"(",
"OptimisticLockException",
"e",
")",
"{",
"// Don't log as error\r",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"OptimisticLockException during the execution of update: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"// BRJ: restore old locking values\r",
"setLockingValues",
"(",
"cld",
",",
"obj",
",",
"oldLockingValues",
")",
";",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of the update: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"final",
"String",
"sql",
"=",
"broker",
".",
"serviceSqlGenerator",
"(",
")",
".",
"getPreparedUpdateStatement",
"(",
"cld",
")",
".",
"getStatement",
"(",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sql",
",",
"cld",
",",
"logger",
",",
"obj",
")",
";",
"}",
"finally",
"{",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"null",
")",
";",
"}",
"}"
] | performs an UPDATE operation against RDBMS.
@param obj The Object to be updated in the underlying table.
@param cld ClassDescriptor providing mapping information. | [
"performs",
"an",
"UPDATE",
"operation",
"against",
"RDBMS",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L481-L559 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.materializeObject | public Object materializeObject(ClassDescriptor cld, Identity oid)
throws PersistenceBrokerException
{
final StatementManagerIF sm = broker.serviceStatementManager();
final SelectStatement sql = broker.serviceSqlGenerator().getPreparedSelectByPkStatement(cld);
Object result = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
stmt = sm.getSelectByPKStatement(cld);
if (stmt == null)
{
logger.error("getSelectByPKStatement returned a null statement");
throw new PersistenceBrokerException("getSelectByPKStatement returned a null statement");
}
/*
arminw: currently a select by PK could never be a stored procedure,
thus we can always set 'false'. Is this correct??
*/
sm.bindSelect(stmt, oid, cld, false);
rs = stmt.executeQuery();
// data available read object, else return null
ResultSetAndStatement rs_stmt = new ResultSetAndStatement(broker.serviceStatementManager(), stmt, rs, sql);
if (rs.next())
{
Map row = new HashMap();
cld.getRowReader().readObjectArrayFrom(rs_stmt, row);
result = cld.getRowReader().readObjectFrom(row);
}
// close resources
rs_stmt.close();
}
catch (PersistenceBrokerException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
logger.error("PersistenceBrokerException during the execution of materializeObject: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
throw ExceptionHelper.generateException(e, sql.getStatement(), cld, logger, null);
}
return result;
} | java | public Object materializeObject(ClassDescriptor cld, Identity oid)
throws PersistenceBrokerException
{
final StatementManagerIF sm = broker.serviceStatementManager();
final SelectStatement sql = broker.serviceSqlGenerator().getPreparedSelectByPkStatement(cld);
Object result = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
stmt = sm.getSelectByPKStatement(cld);
if (stmt == null)
{
logger.error("getSelectByPKStatement returned a null statement");
throw new PersistenceBrokerException("getSelectByPKStatement returned a null statement");
}
/*
arminw: currently a select by PK could never be a stored procedure,
thus we can always set 'false'. Is this correct??
*/
sm.bindSelect(stmt, oid, cld, false);
rs = stmt.executeQuery();
// data available read object, else return null
ResultSetAndStatement rs_stmt = new ResultSetAndStatement(broker.serviceStatementManager(), stmt, rs, sql);
if (rs.next())
{
Map row = new HashMap();
cld.getRowReader().readObjectArrayFrom(rs_stmt, row);
result = cld.getRowReader().readObjectFrom(row);
}
// close resources
rs_stmt.close();
}
catch (PersistenceBrokerException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
logger.error("PersistenceBrokerException during the execution of materializeObject: " + e.getMessage(), e);
throw e;
}
catch (SQLException e)
{
// release resources on exception
sm.closeResources(stmt, rs);
throw ExceptionHelper.generateException(e, sql.getStatement(), cld, logger, null);
}
return result;
} | [
"public",
"Object",
"materializeObject",
"(",
"ClassDescriptor",
"cld",
",",
"Identity",
"oid",
")",
"throws",
"PersistenceBrokerException",
"{",
"final",
"StatementManagerIF",
"sm",
"=",
"broker",
".",
"serviceStatementManager",
"(",
")",
";",
"final",
"SelectStatement",
"sql",
"=",
"broker",
".",
"serviceSqlGenerator",
"(",
")",
".",
"getPreparedSelectByPkStatement",
"(",
"cld",
")",
";",
"Object",
"result",
"=",
"null",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"stmt",
"=",
"sm",
".",
"getSelectByPKStatement",
"(",
"cld",
")",
";",
"if",
"(",
"stmt",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"getSelectByPKStatement returned a null statement\"",
")",
";",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"getSelectByPKStatement returned a null statement\"",
")",
";",
"}",
"/*\r\n arminw: currently a select by PK could never be a stored procedure,\r\n thus we can always set 'false'. Is this correct??\r\n */",
"sm",
".",
"bindSelect",
"(",
"stmt",
",",
"oid",
",",
"cld",
",",
"false",
")",
";",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
")",
";",
"// data available read object, else return null\r",
"ResultSetAndStatement",
"rs_stmt",
"=",
"new",
"ResultSetAndStatement",
"(",
"broker",
".",
"serviceStatementManager",
"(",
")",
",",
"stmt",
",",
"rs",
",",
"sql",
")",
";",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"Map",
"row",
"=",
"new",
"HashMap",
"(",
")",
";",
"cld",
".",
"getRowReader",
"(",
")",
".",
"readObjectArrayFrom",
"(",
"rs_stmt",
",",
"row",
")",
";",
"result",
"=",
"cld",
".",
"getRowReader",
"(",
")",
".",
"readObjectFrom",
"(",
"row",
")",
";",
"}",
"// close resources\r",
"rs_stmt",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"PersistenceBrokerException",
"e",
")",
"{",
"// release resources on exception\r",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"rs",
")",
";",
"logger",
".",
"error",
"(",
"\"PersistenceBrokerException during the execution of materializeObject: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"// release resources on exception\r",
"sm",
".",
"closeResources",
"(",
"stmt",
",",
"rs",
")",
";",
"throw",
"ExceptionHelper",
".",
"generateException",
"(",
"e",
",",
"sql",
".",
"getStatement",
"(",
")",
",",
"cld",
",",
"logger",
",",
"null",
")",
";",
"}",
"return",
"result",
";",
"}"
] | performs a primary key lookup operation against RDBMS and materializes
an object from the resulting row. Only skalar attributes are filled from
the row, references are not resolved.
@param oid contains the primary key info.
@param cld ClassDescriptor providing mapping information.
@return the materialized object, null if no matching row was found or if
any error occured. | [
"performs",
"a",
"primary",
"key",
"lookup",
"operation",
"against",
"RDBMS",
"and",
"materializes",
"an",
"object",
"from",
"the",
"resulting",
"row",
".",
"Only",
"skalar",
"attributes",
"are",
"filled",
"from",
"the",
"row",
"references",
"are",
"not",
"resolved",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L570-L617 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.setLockingValues | private void setLockingValues(ClassDescriptor cld, Object obj, ValueContainer[] oldLockingValues)
{
FieldDescriptor fields[] = cld.getLockingFields();
for (int i=0; i<fields.length; i++)
{
PersistentField field = fields[i].getPersistentField();
Object lockVal = oldLockingValues[i].getValue();
field.set(obj, lockVal);
}
} | java | private void setLockingValues(ClassDescriptor cld, Object obj, ValueContainer[] oldLockingValues)
{
FieldDescriptor fields[] = cld.getLockingFields();
for (int i=0; i<fields.length; i++)
{
PersistentField field = fields[i].getPersistentField();
Object lockVal = oldLockingValues[i].getValue();
field.set(obj, lockVal);
}
} | [
"private",
"void",
"setLockingValues",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"obj",
",",
"ValueContainer",
"[",
"]",
"oldLockingValues",
")",
"{",
"FieldDescriptor",
"fields",
"[",
"]",
"=",
"cld",
".",
"getLockingFields",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"PersistentField",
"field",
"=",
"fields",
"[",
"i",
"]",
".",
"getPersistentField",
"(",
")",
";",
"Object",
"lockVal",
"=",
"oldLockingValues",
"[",
"i",
"]",
".",
"getValue",
"(",
")",
";",
"field",
".",
"set",
"(",
"obj",
",",
"lockVal",
")",
";",
"}",
"}"
] | Set the locking values
@param cld
@param obj
@param oldLockingValues | [
"Set",
"the",
"locking",
"values"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L625-L636 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.harvestReturnValues | private void harvestReturnValues(
ProcedureDescriptor proc,
Object obj,
PreparedStatement stmt)
throws PersistenceBrokerSQLException
{
// If the procedure descriptor is null or has no return values or
// if the statement is not a callable statment, then we're done.
if ((proc == null) || (!proc.hasReturnValues()))
{
return;
}
// Set up the callable statement
CallableStatement callable = (CallableStatement) stmt;
// This is the index that we'll use to harvest the return value(s).
int index = 0;
// If the proc has a return value, then try to harvest it.
if (proc.hasReturnValue())
{
// Increment the index
index++;
// Harvest the value.
this.harvestReturnValue(obj, callable, proc.getReturnValueFieldRef(), index);
}
// Check each argument. If it's returned by the procedure,
// then harvest the value.
Iterator iter = proc.getArguments().iterator();
while (iter.hasNext())
{
index++;
ArgumentDescriptor arg = (ArgumentDescriptor) iter.next();
if (arg.getIsReturnedByProcedure())
{
this.harvestReturnValue(obj, callable, arg.getFieldRef(), index);
}
}
} | java | private void harvestReturnValues(
ProcedureDescriptor proc,
Object obj,
PreparedStatement stmt)
throws PersistenceBrokerSQLException
{
// If the procedure descriptor is null or has no return values or
// if the statement is not a callable statment, then we're done.
if ((proc == null) || (!proc.hasReturnValues()))
{
return;
}
// Set up the callable statement
CallableStatement callable = (CallableStatement) stmt;
// This is the index that we'll use to harvest the return value(s).
int index = 0;
// If the proc has a return value, then try to harvest it.
if (proc.hasReturnValue())
{
// Increment the index
index++;
// Harvest the value.
this.harvestReturnValue(obj, callable, proc.getReturnValueFieldRef(), index);
}
// Check each argument. If it's returned by the procedure,
// then harvest the value.
Iterator iter = proc.getArguments().iterator();
while (iter.hasNext())
{
index++;
ArgumentDescriptor arg = (ArgumentDescriptor) iter.next();
if (arg.getIsReturnedByProcedure())
{
this.harvestReturnValue(obj, callable, arg.getFieldRef(), index);
}
}
} | [
"private",
"void",
"harvestReturnValues",
"(",
"ProcedureDescriptor",
"proc",
",",
"Object",
"obj",
",",
"PreparedStatement",
"stmt",
")",
"throws",
"PersistenceBrokerSQLException",
"{",
"// If the procedure descriptor is null or has no return values or\r",
"// if the statement is not a callable statment, then we're done.\r",
"if",
"(",
"(",
"proc",
"==",
"null",
")",
"||",
"(",
"!",
"proc",
".",
"hasReturnValues",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"// Set up the callable statement\r",
"CallableStatement",
"callable",
"=",
"(",
"CallableStatement",
")",
"stmt",
";",
"// This is the index that we'll use to harvest the return value(s).\r",
"int",
"index",
"=",
"0",
";",
"// If the proc has a return value, then try to harvest it.\r",
"if",
"(",
"proc",
".",
"hasReturnValue",
"(",
")",
")",
"{",
"// Increment the index\r",
"index",
"++",
";",
"// Harvest the value.\r",
"this",
".",
"harvestReturnValue",
"(",
"obj",
",",
"callable",
",",
"proc",
".",
"getReturnValueFieldRef",
"(",
")",
",",
"index",
")",
";",
"}",
"// Check each argument. If it's returned by the procedure,\r",
"// then harvest the value.\r",
"Iterator",
"iter",
"=",
"proc",
".",
"getArguments",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"index",
"++",
";",
"ArgumentDescriptor",
"arg",
"=",
"(",
"ArgumentDescriptor",
")",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"arg",
".",
"getIsReturnedByProcedure",
"(",
")",
")",
"{",
"this",
".",
"harvestReturnValue",
"(",
"obj",
",",
"callable",
",",
"arg",
".",
"getFieldRef",
"(",
")",
",",
"index",
")",
";",
"}",
"}",
"}"
] | Harvest any values that may have been returned during the execution
of a procedure.
@param proc the procedure descriptor that provides info about the procedure
that was invoked.
@param obj the object that was persisted
@param stmt the statement that was used to persist the object.
@throws PersistenceBrokerSQLException if a problem occurs. | [
"Harvest",
"any",
"values",
"that",
"may",
"have",
"been",
"returned",
"during",
"the",
"execution",
"of",
"a",
"procedure",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L649-L691 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.harvestReturnValue | private void harvestReturnValue(
Object obj,
CallableStatement callable,
FieldDescriptor fmd,
int index)
throws PersistenceBrokerSQLException
{
try
{
// If we have a field descriptor, then we can harvest
// the return value.
if ((callable != null) && (fmd != null) && (obj != null))
{
// Get the value and convert it to it's appropriate
// java type.
Object value = fmd.getJdbcType().getObjectFromColumn(callable, index);
// Set the value of the persistent field.
fmd.getPersistentField().set(obj, fmd.getFieldConversion().sqlToJava(value));
}
}
catch (SQLException e)
{
String msg = "SQLException during the execution of harvestReturnValue"
+ " class="
+ obj.getClass().getName()
+ ","
+ " field="
+ fmd.getAttributeName()
+ " : "
+ e.getMessage();
logger.error(msg,e);
throw new PersistenceBrokerSQLException(msg, e);
}
} | java | private void harvestReturnValue(
Object obj,
CallableStatement callable,
FieldDescriptor fmd,
int index)
throws PersistenceBrokerSQLException
{
try
{
// If we have a field descriptor, then we can harvest
// the return value.
if ((callable != null) && (fmd != null) && (obj != null))
{
// Get the value and convert it to it's appropriate
// java type.
Object value = fmd.getJdbcType().getObjectFromColumn(callable, index);
// Set the value of the persistent field.
fmd.getPersistentField().set(obj, fmd.getFieldConversion().sqlToJava(value));
}
}
catch (SQLException e)
{
String msg = "SQLException during the execution of harvestReturnValue"
+ " class="
+ obj.getClass().getName()
+ ","
+ " field="
+ fmd.getAttributeName()
+ " : "
+ e.getMessage();
logger.error(msg,e);
throw new PersistenceBrokerSQLException(msg, e);
}
} | [
"private",
"void",
"harvestReturnValue",
"(",
"Object",
"obj",
",",
"CallableStatement",
"callable",
",",
"FieldDescriptor",
"fmd",
",",
"int",
"index",
")",
"throws",
"PersistenceBrokerSQLException",
"{",
"try",
"{",
"// If we have a field descriptor, then we can harvest\r",
"// the return value.\r",
"if",
"(",
"(",
"callable",
"!=",
"null",
")",
"&&",
"(",
"fmd",
"!=",
"null",
")",
"&&",
"(",
"obj",
"!=",
"null",
")",
")",
"{",
"// Get the value and convert it to it's appropriate\r",
"// java type.\r",
"Object",
"value",
"=",
"fmd",
".",
"getJdbcType",
"(",
")",
".",
"getObjectFromColumn",
"(",
"callable",
",",
"index",
")",
";",
"// Set the value of the persistent field.\r",
"fmd",
".",
"getPersistentField",
"(",
")",
".",
"set",
"(",
"obj",
",",
"fmd",
".",
"getFieldConversion",
"(",
")",
".",
"sqlToJava",
"(",
"value",
")",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"String",
"msg",
"=",
"\"SQLException during the execution of harvestReturnValue\"",
"+",
"\" class=\"",
"+",
"obj",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\",\"",
"+",
"\" field=\"",
"+",
"fmd",
".",
"getAttributeName",
"(",
")",
"+",
"\" : \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"logger",
".",
"error",
"(",
"msg",
",",
"e",
")",
";",
"throw",
"new",
"PersistenceBrokerSQLException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"}"
] | Harvest a single value that was returned by a callable statement.
@param obj the object that will receive the value that is harvested.
@param callable the CallableStatement that contains the value to harvest
@param fmd the FieldDescriptor that identifies the field where the
harvested value will be stord.
@param index the parameter index.
@throws PersistenceBrokerSQLException if a problem occurs. | [
"Harvest",
"a",
"single",
"value",
"that",
"was",
"returned",
"by",
"a",
"callable",
"statement",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L704-L740 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.isStoredProcedure | protected boolean isStoredProcedure(String sql)
{
/*
Stored procedures start with
{?= call <procedure-name>[<arg1>,<arg2>, ...]}
or
{call <procedure-name>[<arg1>,<arg2>, ...]}
but also statements with white space like
{ ?= call <procedure-name>[<arg1>,<arg2>, ...]}
are possible.
*/
int k = 0, i = 0;
char c;
while(k < 3 && i < sql.length())
{
c = sql.charAt(i);
if(c != ' ')
{
switch (k)
{
case 0:
if(c != '{') return false;
break;
case 1:
if(c != '?' && c != 'c') return false;
break;
case 2:
if(c != '=' && c != 'a') return false;
break;
}
k++;
}
i++;
}
return true;
} | java | protected boolean isStoredProcedure(String sql)
{
/*
Stored procedures start with
{?= call <procedure-name>[<arg1>,<arg2>, ...]}
or
{call <procedure-name>[<arg1>,<arg2>, ...]}
but also statements with white space like
{ ?= call <procedure-name>[<arg1>,<arg2>, ...]}
are possible.
*/
int k = 0, i = 0;
char c;
while(k < 3 && i < sql.length())
{
c = sql.charAt(i);
if(c != ' ')
{
switch (k)
{
case 0:
if(c != '{') return false;
break;
case 1:
if(c != '?' && c != 'c') return false;
break;
case 2:
if(c != '=' && c != 'a') return false;
break;
}
k++;
}
i++;
}
return true;
} | [
"protected",
"boolean",
"isStoredProcedure",
"(",
"String",
"sql",
")",
"{",
"/*\r\n Stored procedures start with\r\n {?= call <procedure-name>[<arg1>,<arg2>, ...]}\r\n or\r\n {call <procedure-name>[<arg1>,<arg2>, ...]}\r\n but also statements with white space like\r\n { ?= call <procedure-name>[<arg1>,<arg2>, ...]}\r\n are possible.\r\n */",
"int",
"k",
"=",
"0",
",",
"i",
"=",
"0",
";",
"char",
"c",
";",
"while",
"(",
"k",
"<",
"3",
"&&",
"i",
"<",
"sql",
".",
"length",
"(",
")",
")",
"{",
"c",
"=",
"sql",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
")",
"{",
"switch",
"(",
"k",
")",
"{",
"case",
"0",
":",
"if",
"(",
"c",
"!=",
"'",
"'",
")",
"return",
"false",
";",
"break",
";",
"case",
"1",
":",
"if",
"(",
"c",
"!=",
"'",
"'",
"&&",
"c",
"!=",
"'",
"'",
")",
"return",
"false",
";",
"break",
";",
"case",
"2",
":",
"if",
"(",
"c",
"!=",
"'",
"'",
"&&",
"c",
"!=",
"'",
"'",
")",
"return",
"false",
";",
"break",
";",
"}",
"k",
"++",
";",
"}",
"i",
"++",
";",
"}",
"return",
"true",
";",
"}"
] | Check if the specified sql-string is a stored procedure
or not.
@param sql The sql query to check
@return <em>True</em> if the query is a stored procedure, else <em>false</em> is returned. | [
"Check",
"if",
"the",
"specified",
"sql",
"-",
"string",
"is",
"a",
"stored",
"procedure",
"or",
"not",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L748-L783 | train |
geomajas/geomajas-project-server | plugin/staticsecurity/staticsecurity/src/main/java/org/geomajas/plugin/staticsecurity/security/AuthenticationTokenGeneratorService.java | AuthenticationTokenGeneratorService.get | public String get() {
synchronized (LOCK) {
if (!initialised) {
// generate the random number
Random rnd = new Random(); // @todo need a different seed, this is now time based and I
// would prefer something different, like an object address
// get the random number, instead of getting an integer and converting that to base64 later,
// we get a string and narrow that down to base64, use the top 6 bits of the characters
// as they are more random than the bottom ones...
rnd.nextBytes(value); // get some random characters
value[3] = BASE64[((value[3] >> 2) & BITS_6)]; // NOSONAR
value[4] = BASE64[((value[4] >> 2) & BITS_6)]; // NOSONAR
value[5] = BASE64[((value[5] >> 2) & BITS_6)]; // NOSONAR
value[6] = BASE64[((value[6] >> 2) & BITS_6)]; // NOSONAR
value[7] = BASE64[((value[7] >> 2) & BITS_6)]; // NOSONAR
// complete the time part in the HIGH value of the token
// this also sets the initial low value
completeToken(rnd);
initialised = true;
}
// fill in LOW value in id
int l = low;
value[0] = BASE64[(l & BITS_6)];
l >>= SHIFT_6;
value[1] = BASE64[(l & BITS_6)];
l >>= SHIFT_6;
value[2] = BASE64[(l & BITS_6)];
String res = new String(value);
// increment LOW
low++;
if (low == LOW_MAX) {
low = 0;
}
if (low == lowLast) {
time = System.currentTimeMillis();
completeToken();
}
return res;
}
} | java | public String get() {
synchronized (LOCK) {
if (!initialised) {
// generate the random number
Random rnd = new Random(); // @todo need a different seed, this is now time based and I
// would prefer something different, like an object address
// get the random number, instead of getting an integer and converting that to base64 later,
// we get a string and narrow that down to base64, use the top 6 bits of the characters
// as they are more random than the bottom ones...
rnd.nextBytes(value); // get some random characters
value[3] = BASE64[((value[3] >> 2) & BITS_6)]; // NOSONAR
value[4] = BASE64[((value[4] >> 2) & BITS_6)]; // NOSONAR
value[5] = BASE64[((value[5] >> 2) & BITS_6)]; // NOSONAR
value[6] = BASE64[((value[6] >> 2) & BITS_6)]; // NOSONAR
value[7] = BASE64[((value[7] >> 2) & BITS_6)]; // NOSONAR
// complete the time part in the HIGH value of the token
// this also sets the initial low value
completeToken(rnd);
initialised = true;
}
// fill in LOW value in id
int l = low;
value[0] = BASE64[(l & BITS_6)];
l >>= SHIFT_6;
value[1] = BASE64[(l & BITS_6)];
l >>= SHIFT_6;
value[2] = BASE64[(l & BITS_6)];
String res = new String(value);
// increment LOW
low++;
if (low == LOW_MAX) {
low = 0;
}
if (low == lowLast) {
time = System.currentTimeMillis();
completeToken();
}
return res;
}
} | [
"public",
"String",
"get",
"(",
")",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"!",
"initialised",
")",
"{",
"// generate the random number",
"Random",
"rnd",
"=",
"new",
"Random",
"(",
")",
";",
"// @todo need a different seed, this is now time based and I",
"// would prefer something different, like an object address",
"// get the random number, instead of getting an integer and converting that to base64 later,",
"// we get a string and narrow that down to base64, use the top 6 bits of the characters",
"// as they are more random than the bottom ones...",
"rnd",
".",
"nextBytes",
"(",
"value",
")",
";",
"// get some random characters",
"value",
"[",
"3",
"]",
"=",
"BASE64",
"[",
"(",
"(",
"value",
"[",
"3",
"]",
">>",
"2",
")",
"&",
"BITS_6",
")",
"]",
";",
"// NOSONAR",
"value",
"[",
"4",
"]",
"=",
"BASE64",
"[",
"(",
"(",
"value",
"[",
"4",
"]",
">>",
"2",
")",
"&",
"BITS_6",
")",
"]",
";",
"// NOSONAR",
"value",
"[",
"5",
"]",
"=",
"BASE64",
"[",
"(",
"(",
"value",
"[",
"5",
"]",
">>",
"2",
")",
"&",
"BITS_6",
")",
"]",
";",
"// NOSONAR",
"value",
"[",
"6",
"]",
"=",
"BASE64",
"[",
"(",
"(",
"value",
"[",
"6",
"]",
">>",
"2",
")",
"&",
"BITS_6",
")",
"]",
";",
"// NOSONAR",
"value",
"[",
"7",
"]",
"=",
"BASE64",
"[",
"(",
"(",
"value",
"[",
"7",
"]",
">>",
"2",
")",
"&",
"BITS_6",
")",
"]",
";",
"// NOSONAR",
"// complete the time part in the HIGH value of the token",
"// this also sets the initial low value",
"completeToken",
"(",
"rnd",
")",
";",
"initialised",
"=",
"true",
";",
"}",
"// fill in LOW value in id",
"int",
"l",
"=",
"low",
";",
"value",
"[",
"0",
"]",
"=",
"BASE64",
"[",
"(",
"l",
"&",
"BITS_6",
")",
"]",
";",
"l",
">>=",
"SHIFT_6",
";",
"value",
"[",
"1",
"]",
"=",
"BASE64",
"[",
"(",
"l",
"&",
"BITS_6",
")",
"]",
";",
"l",
">>=",
"SHIFT_6",
";",
"value",
"[",
"2",
"]",
"=",
"BASE64",
"[",
"(",
"l",
"&",
"BITS_6",
")",
"]",
";",
"String",
"res",
"=",
"new",
"String",
"(",
"value",
")",
";",
"// increment LOW",
"low",
"++",
";",
"if",
"(",
"low",
"==",
"LOW_MAX",
")",
"{",
"low",
"=",
"0",
";",
"}",
"if",
"(",
"low",
"==",
"lowLast",
")",
"{",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"completeToken",
"(",
")",
";",
"}",
"return",
"res",
";",
"}",
"}"
] | Get a new token.
@return 14 character String | [
"Get",
"a",
"new",
"token",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/plugin/staticsecurity/staticsecurity/src/main/java/org/geomajas/plugin/staticsecurity/security/AuthenticationTokenGeneratorService.java#L79-L124 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java | LockManagerInMemoryImpl.removeReader | public boolean removeReader(Object key, Object resourceId)
{
boolean result = false;
ObjectLocks objectLocks = null;
synchronized(locktable)
{
objectLocks = (ObjectLocks) locktable.get(resourceId);
if(objectLocks != null)
{
/**
* MBAIRD, last one out, close the door and turn off the lights.
* if no locks (readers or writers) exist for this object, let's remove
* it from the locktable.
*/
Map readers = objectLocks.getReaders();
result = readers.remove(key) != null;
if((objectLocks.getWriter() == null) && (readers.size() == 0))
{
locktable.remove(resourceId);
}
}
}
return result;
} | java | public boolean removeReader(Object key, Object resourceId)
{
boolean result = false;
ObjectLocks objectLocks = null;
synchronized(locktable)
{
objectLocks = (ObjectLocks) locktable.get(resourceId);
if(objectLocks != null)
{
/**
* MBAIRD, last one out, close the door and turn off the lights.
* if no locks (readers or writers) exist for this object, let's remove
* it from the locktable.
*/
Map readers = objectLocks.getReaders();
result = readers.remove(key) != null;
if((objectLocks.getWriter() == null) && (readers.size() == 0))
{
locktable.remove(resourceId);
}
}
}
return result;
} | [
"public",
"boolean",
"removeReader",
"(",
"Object",
"key",
",",
"Object",
"resourceId",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"ObjectLocks",
"objectLocks",
"=",
"null",
";",
"synchronized",
"(",
"locktable",
")",
"{",
"objectLocks",
"=",
"(",
"ObjectLocks",
")",
"locktable",
".",
"get",
"(",
"resourceId",
")",
";",
"if",
"(",
"objectLocks",
"!=",
"null",
")",
"{",
"/**\r\n * MBAIRD, last one out, close the door and turn off the lights.\r\n * if no locks (readers or writers) exist for this object, let's remove\r\n * it from the locktable.\r\n */",
"Map",
"readers",
"=",
"objectLocks",
".",
"getReaders",
"(",
")",
";",
"result",
"=",
"readers",
".",
"remove",
"(",
"key",
")",
"!=",
"null",
";",
"if",
"(",
"(",
"objectLocks",
".",
"getWriter",
"(",
")",
"==",
"null",
")",
"&&",
"(",
"readers",
".",
"size",
"(",
")",
"==",
"0",
")",
")",
"{",
"locktable",
".",
"remove",
"(",
"resourceId",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Remove an read lock. | [
"Remove",
"an",
"read",
"lock",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java#L191-L214 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java | LockManagerInMemoryImpl.removeWriter | public boolean removeWriter(Object key, Object resourceId)
{
boolean result = false;
ObjectLocks objectLocks = null;
synchronized(locktable)
{
objectLocks = (ObjectLocks) locktable.get(resourceId);
if(objectLocks != null)
{
/**
* MBAIRD, last one out, close the door and turn off the lights.
* if no locks (readers or writers) exist for this object, let's remove
* it from the locktable.
*/
LockEntry entry = objectLocks.getWriter();
if(entry != null && entry.isOwnedBy(key))
{
objectLocks.setWriter(null);
result = true;
// no need to check if writer is null, we just set it.
if(objectLocks.getReaders().size() == 0)
{
locktable.remove(resourceId);
}
}
}
}
return result;
} | java | public boolean removeWriter(Object key, Object resourceId)
{
boolean result = false;
ObjectLocks objectLocks = null;
synchronized(locktable)
{
objectLocks = (ObjectLocks) locktable.get(resourceId);
if(objectLocks != null)
{
/**
* MBAIRD, last one out, close the door and turn off the lights.
* if no locks (readers or writers) exist for this object, let's remove
* it from the locktable.
*/
LockEntry entry = objectLocks.getWriter();
if(entry != null && entry.isOwnedBy(key))
{
objectLocks.setWriter(null);
result = true;
// no need to check if writer is null, we just set it.
if(objectLocks.getReaders().size() == 0)
{
locktable.remove(resourceId);
}
}
}
}
return result;
} | [
"public",
"boolean",
"removeWriter",
"(",
"Object",
"key",
",",
"Object",
"resourceId",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"ObjectLocks",
"objectLocks",
"=",
"null",
";",
"synchronized",
"(",
"locktable",
")",
"{",
"objectLocks",
"=",
"(",
"ObjectLocks",
")",
"locktable",
".",
"get",
"(",
"resourceId",
")",
";",
"if",
"(",
"objectLocks",
"!=",
"null",
")",
"{",
"/**\r\n * MBAIRD, last one out, close the door and turn off the lights.\r\n * if no locks (readers or writers) exist for this object, let's remove\r\n * it from the locktable.\r\n */",
"LockEntry",
"entry",
"=",
"objectLocks",
".",
"getWriter",
"(",
")",
";",
"if",
"(",
"entry",
"!=",
"null",
"&&",
"entry",
".",
"isOwnedBy",
"(",
"key",
")",
")",
"{",
"objectLocks",
".",
"setWriter",
"(",
"null",
")",
";",
"result",
"=",
"true",
";",
"// no need to check if writer is null, we just set it.\r",
"if",
"(",
"objectLocks",
".",
"getReaders",
"(",
")",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"locktable",
".",
"remove",
"(",
"resourceId",
")",
";",
"}",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Remove an write lock. | [
"Remove",
"an",
"write",
"lock",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java#L219-L248 | train |
geomajas/geomajas-project-server | impl/src/main/java/org/geomajas/internal/layer/vector/GetFeaturesStyleStep.java | GetFeaturesStyleStep.initStyleFilters | private List<StyleFilter> initStyleFilters(List<FeatureStyleInfo> styleDefinitions) throws GeomajasException {
List<StyleFilter> styleFilters = new ArrayList<StyleFilter>();
if (styleDefinitions == null || styleDefinitions.size() == 0) {
styleFilters.add(new StyleFilterImpl()); // use default.
} else {
for (FeatureStyleInfo styleDef : styleDefinitions) {
StyleFilterImpl styleFilterImpl = null;
String formula = styleDef.getFormula();
if (null != formula && formula.length() > 0) {
styleFilterImpl = new StyleFilterImpl(filterService.parseFilter(formula), styleDef);
} else {
styleFilterImpl = new StyleFilterImpl(Filter.INCLUDE, styleDef);
}
styleFilters.add(styleFilterImpl);
}
}
return styleFilters;
} | java | private List<StyleFilter> initStyleFilters(List<FeatureStyleInfo> styleDefinitions) throws GeomajasException {
List<StyleFilter> styleFilters = new ArrayList<StyleFilter>();
if (styleDefinitions == null || styleDefinitions.size() == 0) {
styleFilters.add(new StyleFilterImpl()); // use default.
} else {
for (FeatureStyleInfo styleDef : styleDefinitions) {
StyleFilterImpl styleFilterImpl = null;
String formula = styleDef.getFormula();
if (null != formula && formula.length() > 0) {
styleFilterImpl = new StyleFilterImpl(filterService.parseFilter(formula), styleDef);
} else {
styleFilterImpl = new StyleFilterImpl(Filter.INCLUDE, styleDef);
}
styleFilters.add(styleFilterImpl);
}
}
return styleFilters;
} | [
"private",
"List",
"<",
"StyleFilter",
">",
"initStyleFilters",
"(",
"List",
"<",
"FeatureStyleInfo",
">",
"styleDefinitions",
")",
"throws",
"GeomajasException",
"{",
"List",
"<",
"StyleFilter",
">",
"styleFilters",
"=",
"new",
"ArrayList",
"<",
"StyleFilter",
">",
"(",
")",
";",
"if",
"(",
"styleDefinitions",
"==",
"null",
"||",
"styleDefinitions",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"styleFilters",
".",
"add",
"(",
"new",
"StyleFilterImpl",
"(",
")",
")",
";",
"// use default.",
"}",
"else",
"{",
"for",
"(",
"FeatureStyleInfo",
"styleDef",
":",
"styleDefinitions",
")",
"{",
"StyleFilterImpl",
"styleFilterImpl",
"=",
"null",
";",
"String",
"formula",
"=",
"styleDef",
".",
"getFormula",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"formula",
"&&",
"formula",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"styleFilterImpl",
"=",
"new",
"StyleFilterImpl",
"(",
"filterService",
".",
"parseFilter",
"(",
"formula",
")",
",",
"styleDef",
")",
";",
"}",
"else",
"{",
"styleFilterImpl",
"=",
"new",
"StyleFilterImpl",
"(",
"Filter",
".",
"INCLUDE",
",",
"styleDef",
")",
";",
"}",
"styleFilters",
".",
"add",
"(",
"styleFilterImpl",
")",
";",
"}",
"}",
"return",
"styleFilters",
";",
"}"
] | Build list of style filters from style definitions.
@param styleDefinitions
list of style definitions
@return list of style filters
@throws GeomajasException | [
"Build",
"list",
"of",
"style",
"filters",
"from",
"style",
"definitions",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/internal/layer/vector/GetFeaturesStyleStep.java#L87-L104 | train |
Axway/Grapes | commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java | ModuleUtils.getAllArtifacts | public static List<Artifact> getAllArtifacts(final Module module){
final List<Artifact> artifacts = new ArrayList<Artifact>();
for(final Module subModule: module.getSubmodules()){
artifacts.addAll(getAllArtifacts(subModule));
}
artifacts.addAll(module.getArtifacts());
return artifacts;
} | java | public static List<Artifact> getAllArtifacts(final Module module){
final List<Artifact> artifacts = new ArrayList<Artifact>();
for(final Module subModule: module.getSubmodules()){
artifacts.addAll(getAllArtifacts(subModule));
}
artifacts.addAll(module.getArtifacts());
return artifacts;
} | [
"public",
"static",
"List",
"<",
"Artifact",
">",
"getAllArtifacts",
"(",
"final",
"Module",
"module",
")",
"{",
"final",
"List",
"<",
"Artifact",
">",
"artifacts",
"=",
"new",
"ArrayList",
"<",
"Artifact",
">",
"(",
")",
";",
"for",
"(",
"final",
"Module",
"subModule",
":",
"module",
".",
"getSubmodules",
"(",
")",
")",
"{",
"artifacts",
".",
"addAll",
"(",
"getAllArtifacts",
"(",
"subModule",
")",
")",
";",
"}",
"artifacts",
".",
"addAll",
"(",
"module",
".",
"getArtifacts",
"(",
")",
")",
";",
"return",
"artifacts",
";",
"}"
] | Returns all the Artifacts of the module
@param module Module
@return List<Artifact> | [
"Returns",
"all",
"the",
"Artifacts",
"of",
"the",
"module"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java#L30-L40 | train |
Axway/Grapes | commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java | ModuleUtils.getAllDependencies | public static List<Dependency> getAllDependencies(final Module module) {
final Set<Dependency> dependencies = new HashSet<Dependency>();
final List<String> producedArtifacts = new ArrayList<String>();
for(final Artifact artifact: getAllArtifacts(module)){
producedArtifacts.add(artifact.getGavc());
}
dependencies.addAll(getAllDependencies(module, producedArtifacts));
return new ArrayList<Dependency>(dependencies);
} | java | public static List<Dependency> getAllDependencies(final Module module) {
final Set<Dependency> dependencies = new HashSet<Dependency>();
final List<String> producedArtifacts = new ArrayList<String>();
for(final Artifact artifact: getAllArtifacts(module)){
producedArtifacts.add(artifact.getGavc());
}
dependencies.addAll(getAllDependencies(module, producedArtifacts));
return new ArrayList<Dependency>(dependencies);
} | [
"public",
"static",
"List",
"<",
"Dependency",
">",
"getAllDependencies",
"(",
"final",
"Module",
"module",
")",
"{",
"final",
"Set",
"<",
"Dependency",
">",
"dependencies",
"=",
"new",
"HashSet",
"<",
"Dependency",
">",
"(",
")",
";",
"final",
"List",
"<",
"String",
">",
"producedArtifacts",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"Artifact",
"artifact",
":",
"getAllArtifacts",
"(",
"module",
")",
")",
"{",
"producedArtifacts",
".",
"add",
"(",
"artifact",
".",
"getGavc",
"(",
")",
")",
";",
"}",
"dependencies",
".",
"addAll",
"(",
"getAllDependencies",
"(",
"module",
",",
"producedArtifacts",
")",
")",
";",
"return",
"new",
"ArrayList",
"<",
"Dependency",
">",
"(",
"dependencies",
")",
";",
"}"
] | Returns all the dependencies of a module
@param module Module
@return List<Dependency> | [
"Returns",
"all",
"the",
"dependencies",
"of",
"a",
"module"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java#L48-L58 | train |
Axway/Grapes | commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java | ModuleUtils.getAllDependencies | public static Set<Dependency> getAllDependencies(final Module module, final List<String> producedArtifacts) {
final Set<Dependency> dependencies = new HashSet<Dependency>();
for(final Dependency dependency: module.getDependencies()){
if(!producedArtifacts.contains(dependency.getTarget().getGavc())){
dependencies.add(dependency);
}
}
for(final Module subModule: module.getSubmodules()){
dependencies.addAll(getAllDependencies(subModule, producedArtifacts));
}
return dependencies;
} | java | public static Set<Dependency> getAllDependencies(final Module module, final List<String> producedArtifacts) {
final Set<Dependency> dependencies = new HashSet<Dependency>();
for(final Dependency dependency: module.getDependencies()){
if(!producedArtifacts.contains(dependency.getTarget().getGavc())){
dependencies.add(dependency);
}
}
for(final Module subModule: module.getSubmodules()){
dependencies.addAll(getAllDependencies(subModule, producedArtifacts));
}
return dependencies;
} | [
"public",
"static",
"Set",
"<",
"Dependency",
">",
"getAllDependencies",
"(",
"final",
"Module",
"module",
",",
"final",
"List",
"<",
"String",
">",
"producedArtifacts",
")",
"{",
"final",
"Set",
"<",
"Dependency",
">",
"dependencies",
"=",
"new",
"HashSet",
"<",
"Dependency",
">",
"(",
")",
";",
"for",
"(",
"final",
"Dependency",
"dependency",
":",
"module",
".",
"getDependencies",
"(",
")",
")",
"{",
"if",
"(",
"!",
"producedArtifacts",
".",
"contains",
"(",
"dependency",
".",
"getTarget",
"(",
")",
".",
"getGavc",
"(",
")",
")",
")",
"{",
"dependencies",
".",
"add",
"(",
"dependency",
")",
";",
"}",
"}",
"for",
"(",
"final",
"Module",
"subModule",
":",
"module",
".",
"getSubmodules",
"(",
")",
")",
"{",
"dependencies",
".",
"addAll",
"(",
"getAllDependencies",
"(",
"subModule",
",",
"producedArtifacts",
")",
")",
";",
"}",
"return",
"dependencies",
";",
"}"
] | Returns all the dependencies taken into account the artifact of the module that will be removed from the dependencies
@param module Module
@param producedArtifacts List<String>
@return Set<Dependency> | [
"Returns",
"all",
"the",
"dependencies",
"taken",
"into",
"account",
"the",
"artifact",
"of",
"the",
"module",
"that",
"will",
"be",
"removed",
"from",
"the",
"dependencies"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java#L67-L81 | train |
Axway/Grapes | commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java | ModuleUtils.getCorporateDependencies | public static List<Dependency> getCorporateDependencies(final Module module, final List<String> corporateFilters) {
final List<Dependency> corporateDependencies = new ArrayList<Dependency>();
final Pattern corporatePattern = generateCorporatePattern(corporateFilters);
for(final Dependency dependency: getAllDependencies(module)){
if(dependency.getTarget().getGavc().matches(corporatePattern.pattern())){
corporateDependencies.add(dependency);
}
}
return corporateDependencies;
} | java | public static List<Dependency> getCorporateDependencies(final Module module, final List<String> corporateFilters) {
final List<Dependency> corporateDependencies = new ArrayList<Dependency>();
final Pattern corporatePattern = generateCorporatePattern(corporateFilters);
for(final Dependency dependency: getAllDependencies(module)){
if(dependency.getTarget().getGavc().matches(corporatePattern.pattern())){
corporateDependencies.add(dependency);
}
}
return corporateDependencies;
} | [
"public",
"static",
"List",
"<",
"Dependency",
">",
"getCorporateDependencies",
"(",
"final",
"Module",
"module",
",",
"final",
"List",
"<",
"String",
">",
"corporateFilters",
")",
"{",
"final",
"List",
"<",
"Dependency",
">",
"corporateDependencies",
"=",
"new",
"ArrayList",
"<",
"Dependency",
">",
"(",
")",
";",
"final",
"Pattern",
"corporatePattern",
"=",
"generateCorporatePattern",
"(",
"corporateFilters",
")",
";",
"for",
"(",
"final",
"Dependency",
"dependency",
":",
"getAllDependencies",
"(",
"module",
")",
")",
"{",
"if",
"(",
"dependency",
".",
"getTarget",
"(",
")",
".",
"getGavc",
"(",
")",
".",
"matches",
"(",
"corporatePattern",
".",
"pattern",
"(",
")",
")",
")",
"{",
"corporateDependencies",
".",
"add",
"(",
"dependency",
")",
";",
"}",
"}",
"return",
"corporateDependencies",
";",
"}"
] | Returns the corporate dependencies of a module
@param module Module
@param corporateFilters List<String>
@return List<Dependency> | [
"Returns",
"the",
"corporate",
"dependencies",
"of",
"a",
"module"
] | ce9cc73d85f83eaa5fbc991abb593915a8c8374e | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/commons/src/main/java/org/axway/grapes/commons/utils/ModuleUtils.java#L91-L102 | train |
kuali/ojb-1.0.4 | src/tools/org/apache/ojb/tools/mapping/reversedb2/dbmetatreemodel/DBMetaTableNode.java | DBMetaTableNode._load | protected boolean _load ()
{
java.sql.ResultSet rs = null;
try
{
// This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1
// The documentation says synchronization is done within the driver, but they
// must have overlooked something. Without the lock we'd get mysterious error
// messages.
synchronized(getDbMeta())
{
getDbMetaTreeModel().setStatusBarMessage("Reading columns for table " + getSchema().getCatalog().getCatalogName() + "." + getSchema().getSchemaName() + "." + getTableName());
rs = getDbMeta().getColumns(getSchema().getCatalog().getCatalogName(),
getSchema().getSchemaName(),
getTableName(), "%");
final java.util.ArrayList alNew = new java.util.ArrayList();
while (rs.next())
{
alNew.add(new DBMetaColumnNode(getDbMeta(), getDbMetaTreeModel(), DBMetaTableNode.this, rs.getString("COLUMN_NAME")));
}
alChildren = alNew;
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
getDbMetaTreeModel().nodeStructureChanged(DBMetaTableNode.this);
}
});
rs.close();
}
}
catch (java.sql.SQLException sqlEx)
{
this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx);
try
{
if (rs != null) rs.close ();
}
catch (java.sql.SQLException sqlEx2)
{
this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx2);
}
return false;
}
return true;
} | java | protected boolean _load ()
{
java.sql.ResultSet rs = null;
try
{
// This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1
// The documentation says synchronization is done within the driver, but they
// must have overlooked something. Without the lock we'd get mysterious error
// messages.
synchronized(getDbMeta())
{
getDbMetaTreeModel().setStatusBarMessage("Reading columns for table " + getSchema().getCatalog().getCatalogName() + "." + getSchema().getSchemaName() + "." + getTableName());
rs = getDbMeta().getColumns(getSchema().getCatalog().getCatalogName(),
getSchema().getSchemaName(),
getTableName(), "%");
final java.util.ArrayList alNew = new java.util.ArrayList();
while (rs.next())
{
alNew.add(new DBMetaColumnNode(getDbMeta(), getDbMetaTreeModel(), DBMetaTableNode.this, rs.getString("COLUMN_NAME")));
}
alChildren = alNew;
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
getDbMetaTreeModel().nodeStructureChanged(DBMetaTableNode.this);
}
});
rs.close();
}
}
catch (java.sql.SQLException sqlEx)
{
this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx);
try
{
if (rs != null) rs.close ();
}
catch (java.sql.SQLException sqlEx2)
{
this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx2);
}
return false;
}
return true;
} | [
"protected",
"boolean",
"_load",
"(",
")",
"{",
"java",
".",
"sql",
".",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"// This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1\r",
"// The documentation says synchronization is done within the driver, but they\r",
"// must have overlooked something. Without the lock we'd get mysterious error\r",
"// messages. \r",
"synchronized",
"(",
"getDbMeta",
"(",
")",
")",
"{",
"getDbMetaTreeModel",
"(",
")",
".",
"setStatusBarMessage",
"(",
"\"Reading columns for table \"",
"+",
"getSchema",
"(",
")",
".",
"getCatalog",
"(",
")",
".",
"getCatalogName",
"(",
")",
"+",
"\".\"",
"+",
"getSchema",
"(",
")",
".",
"getSchemaName",
"(",
")",
"+",
"\".\"",
"+",
"getTableName",
"(",
")",
")",
";",
"rs",
"=",
"getDbMeta",
"(",
")",
".",
"getColumns",
"(",
"getSchema",
"(",
")",
".",
"getCatalog",
"(",
")",
".",
"getCatalogName",
"(",
")",
",",
"getSchema",
"(",
")",
".",
"getSchemaName",
"(",
")",
",",
"getTableName",
"(",
")",
",",
"\"%\"",
")",
";",
"final",
"java",
".",
"util",
".",
"ArrayList",
"alNew",
"=",
"new",
"java",
".",
"util",
".",
"ArrayList",
"(",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"alNew",
".",
"add",
"(",
"new",
"DBMetaColumnNode",
"(",
"getDbMeta",
"(",
")",
",",
"getDbMetaTreeModel",
"(",
")",
",",
"DBMetaTableNode",
".",
"this",
",",
"rs",
".",
"getString",
"(",
"\"COLUMN_NAME\"",
")",
")",
")",
";",
"}",
"alChildren",
"=",
"alNew",
";",
"javax",
".",
"swing",
".",
"SwingUtilities",
".",
"invokeLater",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"getDbMetaTreeModel",
"(",
")",
".",
"nodeStructureChanged",
"(",
"DBMetaTableNode",
".",
"this",
")",
";",
"}",
"}",
")",
";",
"rs",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"java",
".",
"sql",
".",
"SQLException",
"sqlEx",
")",
"{",
"this",
".",
"getDbMetaTreeModel",
"(",
")",
".",
"reportSqlError",
"(",
"\"Error retrieving columns\"",
",",
"sqlEx",
")",
";",
"try",
"{",
"if",
"(",
"rs",
"!=",
"null",
")",
"rs",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"java",
".",
"sql",
".",
"SQLException",
"sqlEx2",
")",
"{",
"this",
".",
"getDbMetaTreeModel",
"(",
")",
".",
"reportSqlError",
"(",
"\"Error retrieving columns\"",
",",
"sqlEx2",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Loads the columns for this table into the alChildren list. | [
"Loads",
"the",
"columns",
"for",
"this",
"table",
"into",
"the",
"alChildren",
"list",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/tools/org/apache/ojb/tools/mapping/reversedb2/dbmetatreemodel/DBMetaTableNode.java#L94-L139 | train |
geomajas/geomajas-project-server | common-servlet/src/main/java/org/geomajas/servlet/ResourceServlet.java | ResourceServlet.configureCaching | private void configureCaching(HttpServletResponse response, int seconds) {
// HTTP 1.0 header
response.setDateHeader(HTTP_EXPIRES_HEADER, System.currentTimeMillis() + seconds * 1000L);
if (seconds > 0) {
// HTTP 1.1 header
response.setHeader(HTTP_CACHE_CONTROL_HEADER, "max-age=" + seconds);
} else {
// HTTP 1.1 header
response.setHeader(HTTP_CACHE_CONTROL_HEADER, "no-cache");
}
} | java | private void configureCaching(HttpServletResponse response, int seconds) {
// HTTP 1.0 header
response.setDateHeader(HTTP_EXPIRES_HEADER, System.currentTimeMillis() + seconds * 1000L);
if (seconds > 0) {
// HTTP 1.1 header
response.setHeader(HTTP_CACHE_CONTROL_HEADER, "max-age=" + seconds);
} else {
// HTTP 1.1 header
response.setHeader(HTTP_CACHE_CONTROL_HEADER, "no-cache");
}
} | [
"private",
"void",
"configureCaching",
"(",
"HttpServletResponse",
"response",
",",
"int",
"seconds",
")",
"{",
"// HTTP 1.0 header",
"response",
".",
"setDateHeader",
"(",
"HTTP_EXPIRES_HEADER",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"seconds",
"*",
"1000L",
")",
";",
"if",
"(",
"seconds",
">",
"0",
")",
"{",
"// HTTP 1.1 header",
"response",
".",
"setHeader",
"(",
"HTTP_CACHE_CONTROL_HEADER",
",",
"\"max-age=\"",
"+",
"seconds",
")",
";",
"}",
"else",
"{",
"// HTTP 1.1 header",
"response",
".",
"setHeader",
"(",
"HTTP_CACHE_CONTROL_HEADER",
",",
"\"no-cache\"",
")",
";",
"}",
"}"
] | Set HTTP headers to allow caching for the given number of seconds.
@param response where to set the caching settings
@param seconds number of seconds into the future that the response should be cacheable for | [
"Set",
"HTTP",
"headers",
"to",
"allow",
"caching",
"for",
"the",
"given",
"number",
"of",
"seconds",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/common-servlet/src/main/java/org/geomajas/servlet/ResourceServlet.java#L337-L348 | train |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/model/FieldWithIdComparator.java | FieldWithIdComparator.compare | public int compare(Object objA, Object objB)
{
String idAStr = ((FieldDescriptorDef)_fields.get(objA)).getProperty("id");
String idBStr = ((FieldDescriptorDef)_fields.get(objB)).getProperty("id");
int idA;
int idB;
try
{
idA = Integer.parseInt(idAStr);
}
catch (Exception ex)
{
return 1;
}
try
{
idB = Integer.parseInt(idBStr);
}
catch (Exception ex)
{
return -1;
}
return idA < idB ? -1 : (idA > idB ? 1 : 0);
} | java | public int compare(Object objA, Object objB)
{
String idAStr = ((FieldDescriptorDef)_fields.get(objA)).getProperty("id");
String idBStr = ((FieldDescriptorDef)_fields.get(objB)).getProperty("id");
int idA;
int idB;
try
{
idA = Integer.parseInt(idAStr);
}
catch (Exception ex)
{
return 1;
}
try
{
idB = Integer.parseInt(idBStr);
}
catch (Exception ex)
{
return -1;
}
return idA < idB ? -1 : (idA > idB ? 1 : 0);
} | [
"public",
"int",
"compare",
"(",
"Object",
"objA",
",",
"Object",
"objB",
")",
"{",
"String",
"idAStr",
"=",
"(",
"(",
"FieldDescriptorDef",
")",
"_fields",
".",
"get",
"(",
"objA",
")",
")",
".",
"getProperty",
"(",
"\"id\"",
")",
";",
"String",
"idBStr",
"=",
"(",
"(",
"FieldDescriptorDef",
")",
"_fields",
".",
"get",
"(",
"objB",
")",
")",
".",
"getProperty",
"(",
"\"id\"",
")",
";",
"int",
"idA",
";",
"int",
"idB",
";",
"try",
"{",
"idA",
"=",
"Integer",
".",
"parseInt",
"(",
"idAStr",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"1",
";",
"}",
"try",
"{",
"idB",
"=",
"Integer",
".",
"parseInt",
"(",
"idBStr",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"idA",
"<",
"idB",
"?",
"-",
"1",
":",
"(",
"idA",
">",
"idB",
"?",
"1",
":",
"0",
")",
";",
"}"
] | Compares two fields given by their names.
@param objA The name of the first field
@param objB The name of the second field
@return
@see java.util.Comparator#compare(java.lang.Object, java.lang.Object) | [
"Compares",
"two",
"fields",
"given",
"by",
"their",
"names",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/model/FieldWithIdComparator.java#L53-L77 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/PkEnumeration.java | PkEnumeration.hasMoreElements | public boolean hasMoreElements()
{
try
{
if (!hasCalledCheck)
{
hasCalledCheck = true;
hasNext = resultSetAndStatment.m_rs.next();
}
}
catch (SQLException e)
{
LoggerFactory.getDefaultLogger().error(e);
//releaseDbResources();
hasNext = false;
}
finally
{
if(!hasNext)
{
releaseDbResources();
}
}
return hasNext;
} | java | public boolean hasMoreElements()
{
try
{
if (!hasCalledCheck)
{
hasCalledCheck = true;
hasNext = resultSetAndStatment.m_rs.next();
}
}
catch (SQLException e)
{
LoggerFactory.getDefaultLogger().error(e);
//releaseDbResources();
hasNext = false;
}
finally
{
if(!hasNext)
{
releaseDbResources();
}
}
return hasNext;
} | [
"public",
"boolean",
"hasMoreElements",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"hasCalledCheck",
")",
"{",
"hasCalledCheck",
"=",
"true",
";",
"hasNext",
"=",
"resultSetAndStatment",
".",
"m_rs",
".",
"next",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"LoggerFactory",
".",
"getDefaultLogger",
"(",
")",
".",
"error",
"(",
"e",
")",
";",
"//releaseDbResources();\r",
"hasNext",
"=",
"false",
";",
"}",
"finally",
"{",
"if",
"(",
"!",
"hasNext",
")",
"{",
"releaseDbResources",
"(",
")",
";",
"}",
"}",
"return",
"hasNext",
";",
"}"
] | Tests if this enumeration contains more elements.
@return <code>true</code> if and only if this enumeration object
contains at least one more element to provide;
<code>false</code> otherwise. | [
"Tests",
"if",
"this",
"enumeration",
"contains",
"more",
"elements",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/PkEnumeration.java#L135-L159 | train |
geomajas/geomajas-project-server | common-servlet/src/main/java/org/geomajas/servlet/mvc/legend/LegendGraphicController.java | LegendGraphicController.getGraphic | @RequestMapping(value = "/legendgraphic", method = RequestMethod.GET)
public ModelAndView getGraphic(@RequestParam("layerId") String layerId,
@RequestParam(value = "styleName", required = false) String styleName,
@RequestParam(value = "ruleIndex", required = false) Integer ruleIndex,
@RequestParam(value = "format", required = false) String format,
@RequestParam(value = "width", required = false) Integer width,
@RequestParam(value = "height", required = false) Integer height,
@RequestParam(value = "scale", required = false) Double scale,
@RequestParam(value = "allRules", required = false) Boolean allRules, HttpServletRequest request)
throws GeomajasException {
if (!allRules) {
return getGraphic(layerId, styleName, ruleIndex, format, width, height, scale);
} else {
return getGraphics(layerId, styleName, format, width, height, scale);
}
} | java | @RequestMapping(value = "/legendgraphic", method = RequestMethod.GET)
public ModelAndView getGraphic(@RequestParam("layerId") String layerId,
@RequestParam(value = "styleName", required = false) String styleName,
@RequestParam(value = "ruleIndex", required = false) Integer ruleIndex,
@RequestParam(value = "format", required = false) String format,
@RequestParam(value = "width", required = false) Integer width,
@RequestParam(value = "height", required = false) Integer height,
@RequestParam(value = "scale", required = false) Double scale,
@RequestParam(value = "allRules", required = false) Boolean allRules, HttpServletRequest request)
throws GeomajasException {
if (!allRules) {
return getGraphic(layerId, styleName, ruleIndex, format, width, height, scale);
} else {
return getGraphics(layerId, styleName, format, width, height, scale);
}
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/legendgraphic\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"public",
"ModelAndView",
"getGraphic",
"(",
"@",
"RequestParam",
"(",
"\"layerId\"",
")",
"String",
"layerId",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"styleName\"",
",",
"required",
"=",
"false",
")",
"String",
"styleName",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"ruleIndex\"",
",",
"required",
"=",
"false",
")",
"Integer",
"ruleIndex",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"format\"",
",",
"required",
"=",
"false",
")",
"String",
"format",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"width\"",
",",
"required",
"=",
"false",
")",
"Integer",
"width",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"height\"",
",",
"required",
"=",
"false",
")",
"Integer",
"height",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"scale\"",
",",
"required",
"=",
"false",
")",
"Double",
"scale",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"allRules\"",
",",
"required",
"=",
"false",
")",
"Boolean",
"allRules",
",",
"HttpServletRequest",
"request",
")",
"throws",
"GeomajasException",
"{",
"if",
"(",
"!",
"allRules",
")",
"{",
"return",
"getGraphic",
"(",
"layerId",
",",
"styleName",
",",
"ruleIndex",
",",
"format",
",",
"width",
",",
"height",
",",
"scale",
")",
";",
"}",
"else",
"{",
"return",
"getGraphics",
"(",
"layerId",
",",
"styleName",
",",
"format",
",",
"width",
",",
"height",
",",
"scale",
")",
";",
"}",
"}"
] | Gets a legend graphic with the specified metadata parameters. All parameters are passed as request parameters.
@param layerId
the layer id
@param styleName
the style name
@param ruleIndex
the rule index
@param format
the image format ('png','jpg','gif')
@param width
the graphic's width
@param height
the graphic's height
@param scale
the scale denominator (not supported yet)
@param allRules
if true the image will contain all rules stacked vertically
@param request
the servlet request object
@return the model and view
@throws GeomajasException
when a style or rule does not exist or is not renderable | [
"Gets",
"a",
"legend",
"graphic",
"with",
"the",
"specified",
"metadata",
"parameters",
".",
"All",
"parameters",
"are",
"passed",
"as",
"request",
"parameters",
"."
] | 904b7d7deed1350d28955589098dd1e0a786d76e | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/common-servlet/src/main/java/org/geomajas/servlet/mvc/legend/LegendGraphicController.java#L81-L96 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/ReadCommittedStrategy.java | ReadCommittedStrategy.checkRead | public boolean checkRead(TransactionImpl tx, Object obj)
{
if (hasReadLock(tx, obj))
{
return true;
}
LockEntry writer = getWriter(obj);
if (writer.isOwnedBy(tx))
{
return true;
}
return false;
} | java | public boolean checkRead(TransactionImpl tx, Object obj)
{
if (hasReadLock(tx, obj))
{
return true;
}
LockEntry writer = getWriter(obj);
if (writer.isOwnedBy(tx))
{
return true;
}
return false;
} | [
"public",
"boolean",
"checkRead",
"(",
"TransactionImpl",
"tx",
",",
"Object",
"obj",
")",
"{",
"if",
"(",
"hasReadLock",
"(",
"tx",
",",
"obj",
")",
")",
"{",
"return",
"true",
";",
"}",
"LockEntry",
"writer",
"=",
"getWriter",
"(",
"obj",
")",
";",
"if",
"(",
"writer",
".",
"isOwnedBy",
"(",
"tx",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | checks whether the specified Object obj is read-locked by Transaction tx.
@param tx the transaction
@param obj the Object to be checked
@return true if lock exists, else false | [
"checks",
"whether",
"the",
"specified",
"Object",
"obj",
"is",
"read",
"-",
"locked",
"by",
"Transaction",
"tx",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/ReadCommittedStrategy.java#L156-L168 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/ReadCommittedStrategy.java | ReadCommittedStrategy.checkWrite | public boolean checkWrite(TransactionImpl tx, Object obj)
{
LockEntry writer = getWriter(obj);
if (writer == null)
return false;
else if (writer.isOwnedBy(tx))
return true;
else
return false;
} | java | public boolean checkWrite(TransactionImpl tx, Object obj)
{
LockEntry writer = getWriter(obj);
if (writer == null)
return false;
else if (writer.isOwnedBy(tx))
return true;
else
return false;
} | [
"public",
"boolean",
"checkWrite",
"(",
"TransactionImpl",
"tx",
",",
"Object",
"obj",
")",
"{",
"LockEntry",
"writer",
"=",
"getWriter",
"(",
"obj",
")",
";",
"if",
"(",
"writer",
"==",
"null",
")",
"return",
"false",
";",
"else",
"if",
"(",
"writer",
".",
"isOwnedBy",
"(",
"tx",
")",
")",
"return",
"true",
";",
"else",
"return",
"false",
";",
"}"
] | checks whether the specified Object obj is write-locked by Transaction tx.
@param tx the transaction
@param obj the Object to be checked
@return true if lock exists, else false | [
"checks",
"whether",
"the",
"specified",
"Object",
"obj",
"is",
"write",
"-",
"locked",
"by",
"Transaction",
"tx",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/ReadCommittedStrategy.java#L176-L185 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/ProxyFactoryJDKImpl.java | ProxyFactoryJDKImpl.getDynamicProxyClass | private Class getDynamicProxyClass(Class baseClass) {
Class[] m_dynamicProxyClassInterfaces;
if (foundInterfaces.containsKey(baseClass)) {
m_dynamicProxyClassInterfaces = (Class[])foundInterfaces.get(baseClass);
} else {
m_dynamicProxyClassInterfaces = getInterfaces(baseClass);
foundInterfaces.put(baseClass, m_dynamicProxyClassInterfaces);
}
// return dynymic Proxy Class implementing all interfaces
Class proxyClazz = Proxy.getProxyClass(baseClass.getClassLoader(), m_dynamicProxyClassInterfaces);
return proxyClazz;
} | java | private Class getDynamicProxyClass(Class baseClass) {
Class[] m_dynamicProxyClassInterfaces;
if (foundInterfaces.containsKey(baseClass)) {
m_dynamicProxyClassInterfaces = (Class[])foundInterfaces.get(baseClass);
} else {
m_dynamicProxyClassInterfaces = getInterfaces(baseClass);
foundInterfaces.put(baseClass, m_dynamicProxyClassInterfaces);
}
// return dynymic Proxy Class implementing all interfaces
Class proxyClazz = Proxy.getProxyClass(baseClass.getClassLoader(), m_dynamicProxyClassInterfaces);
return proxyClazz;
} | [
"private",
"Class",
"getDynamicProxyClass",
"(",
"Class",
"baseClass",
")",
"{",
"Class",
"[",
"]",
"m_dynamicProxyClassInterfaces",
";",
"if",
"(",
"foundInterfaces",
".",
"containsKey",
"(",
"baseClass",
")",
")",
"{",
"m_dynamicProxyClassInterfaces",
"=",
"(",
"Class",
"[",
"]",
")",
"foundInterfaces",
".",
"get",
"(",
"baseClass",
")",
";",
"}",
"else",
"{",
"m_dynamicProxyClassInterfaces",
"=",
"getInterfaces",
"(",
"baseClass",
")",
";",
"foundInterfaces",
".",
"put",
"(",
"baseClass",
",",
"m_dynamicProxyClassInterfaces",
")",
";",
"}",
"// return dynymic Proxy Class implementing all interfaces\r",
"Class",
"proxyClazz",
"=",
"Proxy",
".",
"getProxyClass",
"(",
"baseClass",
".",
"getClassLoader",
"(",
")",
",",
"m_dynamicProxyClassInterfaces",
")",
";",
"return",
"proxyClazz",
";",
"}"
] | returns a dynamic Proxy that implements all interfaces of the
class described by this ClassDescriptor.
@return Class the dynamically created proxy class | [
"returns",
"a",
"dynamic",
"Proxy",
"that",
"implements",
"all",
"interfaces",
"of",
"the",
"class",
"described",
"by",
"this",
"ClassDescriptor",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/ProxyFactoryJDKImpl.java#L75-L87 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/ProxyFactoryJDKImpl.java | ProxyFactoryJDKImpl.getInterfaces | private Class[] getInterfaces(Class clazz) {
Class superClazz = clazz;
Class[] interfaces = clazz.getInterfaces();
// clazz can be an interface itself and when getInterfaces()
// is called on an interface it returns only the extending
// interfaces, not the interface itself.
if (clazz.isInterface()) {
Class[] tempInterfaces = new Class[interfaces.length + 1];
tempInterfaces[0] = clazz;
System.arraycopy(interfaces, 0, tempInterfaces, 1, interfaces.length);
interfaces = tempInterfaces;
}
// add all interfaces implemented by superclasses to the interfaces array
while ((superClazz = superClazz.getSuperclass()) != null) {
Class[] superInterfaces = superClazz.getInterfaces();
Class[] combInterfaces = new Class[interfaces.length + superInterfaces.length];
System.arraycopy(interfaces, 0, combInterfaces, 0, interfaces.length);
System.arraycopy(superInterfaces, 0, combInterfaces, interfaces.length, superInterfaces.length);
interfaces = combInterfaces;
}
/**
* Must remove duplicate interfaces before calling Proxy.getProxyClass().
* Duplicates can occur if a subclass re-declares that it implements
* the same interface as one of its ancestor classes.
**/
HashMap unique = new HashMap();
for (int i = 0; i < interfaces.length; i++) {
unique.put(interfaces[i].getName(), interfaces[i]);
}
/* Add the OJBProxy interface as well */
unique.put(OJBProxy.class.getName(), OJBProxy.class);
interfaces = (Class[])unique.values().toArray(new Class[unique.size()]);
return interfaces;
} | java | private Class[] getInterfaces(Class clazz) {
Class superClazz = clazz;
Class[] interfaces = clazz.getInterfaces();
// clazz can be an interface itself and when getInterfaces()
// is called on an interface it returns only the extending
// interfaces, not the interface itself.
if (clazz.isInterface()) {
Class[] tempInterfaces = new Class[interfaces.length + 1];
tempInterfaces[0] = clazz;
System.arraycopy(interfaces, 0, tempInterfaces, 1, interfaces.length);
interfaces = tempInterfaces;
}
// add all interfaces implemented by superclasses to the interfaces array
while ((superClazz = superClazz.getSuperclass()) != null) {
Class[] superInterfaces = superClazz.getInterfaces();
Class[] combInterfaces = new Class[interfaces.length + superInterfaces.length];
System.arraycopy(interfaces, 0, combInterfaces, 0, interfaces.length);
System.arraycopy(superInterfaces, 0, combInterfaces, interfaces.length, superInterfaces.length);
interfaces = combInterfaces;
}
/**
* Must remove duplicate interfaces before calling Proxy.getProxyClass().
* Duplicates can occur if a subclass re-declares that it implements
* the same interface as one of its ancestor classes.
**/
HashMap unique = new HashMap();
for (int i = 0; i < interfaces.length; i++) {
unique.put(interfaces[i].getName(), interfaces[i]);
}
/* Add the OJBProxy interface as well */
unique.put(OJBProxy.class.getName(), OJBProxy.class);
interfaces = (Class[])unique.values().toArray(new Class[unique.size()]);
return interfaces;
} | [
"private",
"Class",
"[",
"]",
"getInterfaces",
"(",
"Class",
"clazz",
")",
"{",
"Class",
"superClazz",
"=",
"clazz",
";",
"Class",
"[",
"]",
"interfaces",
"=",
"clazz",
".",
"getInterfaces",
"(",
")",
";",
"// clazz can be an interface itself and when getInterfaces()\r",
"// is called on an interface it returns only the extending\r",
"// interfaces, not the interface itself.\r",
"if",
"(",
"clazz",
".",
"isInterface",
"(",
")",
")",
"{",
"Class",
"[",
"]",
"tempInterfaces",
"=",
"new",
"Class",
"[",
"interfaces",
".",
"length",
"+",
"1",
"]",
";",
"tempInterfaces",
"[",
"0",
"]",
"=",
"clazz",
";",
"System",
".",
"arraycopy",
"(",
"interfaces",
",",
"0",
",",
"tempInterfaces",
",",
"1",
",",
"interfaces",
".",
"length",
")",
";",
"interfaces",
"=",
"tempInterfaces",
";",
"}",
"// add all interfaces implemented by superclasses to the interfaces array\r",
"while",
"(",
"(",
"superClazz",
"=",
"superClazz",
".",
"getSuperclass",
"(",
")",
")",
"!=",
"null",
")",
"{",
"Class",
"[",
"]",
"superInterfaces",
"=",
"superClazz",
".",
"getInterfaces",
"(",
")",
";",
"Class",
"[",
"]",
"combInterfaces",
"=",
"new",
"Class",
"[",
"interfaces",
".",
"length",
"+",
"superInterfaces",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"interfaces",
",",
"0",
",",
"combInterfaces",
",",
"0",
",",
"interfaces",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"superInterfaces",
",",
"0",
",",
"combInterfaces",
",",
"interfaces",
".",
"length",
",",
"superInterfaces",
".",
"length",
")",
";",
"interfaces",
"=",
"combInterfaces",
";",
"}",
"/**\r\n * Must remove duplicate interfaces before calling Proxy.getProxyClass().\r\n * Duplicates can occur if a subclass re-declares that it implements\r\n * the same interface as one of its ancestor classes.\r\n **/",
"HashMap",
"unique",
"=",
"new",
"HashMap",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"interfaces",
".",
"length",
";",
"i",
"++",
")",
"{",
"unique",
".",
"put",
"(",
"interfaces",
"[",
"i",
"]",
".",
"getName",
"(",
")",
",",
"interfaces",
"[",
"i",
"]",
")",
";",
"}",
"/* Add the OJBProxy interface as well */",
"unique",
".",
"put",
"(",
"OJBProxy",
".",
"class",
".",
"getName",
"(",
")",
",",
"OJBProxy",
".",
"class",
")",
";",
"interfaces",
"=",
"(",
"Class",
"[",
"]",
")",
"unique",
".",
"values",
"(",
")",
".",
"toArray",
"(",
"new",
"Class",
"[",
"unique",
".",
"size",
"(",
")",
"]",
")",
";",
"return",
"interfaces",
";",
"}"
] | Get interfaces implemented by clazz
@param clazz
@return | [
"Get",
"interfaces",
"implemented",
"by",
"clazz"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/ProxyFactoryJDKImpl.java#L95-L134 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/collections/DMapEntry.java | DMapEntry.getRealKey | public Object getRealKey()
{
if(keyRealSubject != null)
{
return keyRealSubject;
}
else
{
TransactionExt tx = getTransaction();
if((tx != null) && tx.isOpen())
{
prepareKeyRealSubject(tx.getBroker());
}
else
{
if(getPBKey() != null)
{
PBCapsule capsule = new PBCapsule(getPBKey(), null);
try
{
prepareKeyRealSubject(capsule.getBroker());
}
finally
{
capsule.destroy();
}
}
else
{
getLog().warn("No tx, no PBKey - can't materialise key with Identity " + getKeyOid());
}
}
}
return keyRealSubject;
} | java | public Object getRealKey()
{
if(keyRealSubject != null)
{
return keyRealSubject;
}
else
{
TransactionExt tx = getTransaction();
if((tx != null) && tx.isOpen())
{
prepareKeyRealSubject(tx.getBroker());
}
else
{
if(getPBKey() != null)
{
PBCapsule capsule = new PBCapsule(getPBKey(), null);
try
{
prepareKeyRealSubject(capsule.getBroker());
}
finally
{
capsule.destroy();
}
}
else
{
getLog().warn("No tx, no PBKey - can't materialise key with Identity " + getKeyOid());
}
}
}
return keyRealSubject;
} | [
"public",
"Object",
"getRealKey",
"(",
")",
"{",
"if",
"(",
"keyRealSubject",
"!=",
"null",
")",
"{",
"return",
"keyRealSubject",
";",
"}",
"else",
"{",
"TransactionExt",
"tx",
"=",
"getTransaction",
"(",
")",
";",
"if",
"(",
"(",
"tx",
"!=",
"null",
")",
"&&",
"tx",
".",
"isOpen",
"(",
")",
")",
"{",
"prepareKeyRealSubject",
"(",
"tx",
".",
"getBroker",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"getPBKey",
"(",
")",
"!=",
"null",
")",
"{",
"PBCapsule",
"capsule",
"=",
"new",
"PBCapsule",
"(",
"getPBKey",
"(",
")",
",",
"null",
")",
";",
"try",
"{",
"prepareKeyRealSubject",
"(",
"capsule",
".",
"getBroker",
"(",
")",
")",
";",
"}",
"finally",
"{",
"capsule",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"warn",
"(",
"\"No tx, no PBKey - can't materialise key with Identity \"",
"+",
"getKeyOid",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"keyRealSubject",
";",
"}"
] | Returns the real key object. | [
"Returns",
"the",
"real",
"key",
"object",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/collections/DMapEntry.java#L162-L198 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/collections/DMapEntry.java | DMapEntry.getRealValue | public Object getRealValue()
{
if(valueRealSubject != null)
{
return valueRealSubject;
}
else
{
TransactionExt tx = getTransaction();
if((tx != null) && tx.isOpen())
{
prepareValueRealSubject(tx.getBroker());
}
else
{
if(getPBKey() != null)
{
PBCapsule capsule = new PBCapsule(getPBKey(), null);
try
{
prepareValueRealSubject(capsule.getBroker());
}
finally
{
capsule.destroy();
}
}
else
{
getLog().warn("No tx, no PBKey - can't materialise value with Identity " + getKeyOid());
}
}
}
return valueRealSubject;
} | java | public Object getRealValue()
{
if(valueRealSubject != null)
{
return valueRealSubject;
}
else
{
TransactionExt tx = getTransaction();
if((tx != null) && tx.isOpen())
{
prepareValueRealSubject(tx.getBroker());
}
else
{
if(getPBKey() != null)
{
PBCapsule capsule = new PBCapsule(getPBKey(), null);
try
{
prepareValueRealSubject(capsule.getBroker());
}
finally
{
capsule.destroy();
}
}
else
{
getLog().warn("No tx, no PBKey - can't materialise value with Identity " + getKeyOid());
}
}
}
return valueRealSubject;
} | [
"public",
"Object",
"getRealValue",
"(",
")",
"{",
"if",
"(",
"valueRealSubject",
"!=",
"null",
")",
"{",
"return",
"valueRealSubject",
";",
"}",
"else",
"{",
"TransactionExt",
"tx",
"=",
"getTransaction",
"(",
")",
";",
"if",
"(",
"(",
"tx",
"!=",
"null",
")",
"&&",
"tx",
".",
"isOpen",
"(",
")",
")",
"{",
"prepareValueRealSubject",
"(",
"tx",
".",
"getBroker",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"getPBKey",
"(",
")",
"!=",
"null",
")",
"{",
"PBCapsule",
"capsule",
"=",
"new",
"PBCapsule",
"(",
"getPBKey",
"(",
")",
",",
"null",
")",
";",
"try",
"{",
"prepareValueRealSubject",
"(",
"capsule",
".",
"getBroker",
"(",
")",
")",
";",
"}",
"finally",
"{",
"capsule",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"warn",
"(",
"\"No tx, no PBKey - can't materialise value with Identity \"",
"+",
"getKeyOid",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"valueRealSubject",
";",
"}"
] | Returns the real value object. | [
"Returns",
"the",
"real",
"value",
"object",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/collections/DMapEntry.java#L220-L256 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/RepositoryPersistor.java | RepositoryPersistor.readMetadataFromXML | private Object readMetadataFromXML(InputSource source, Class target)
throws MalformedURLException, ParserConfigurationException, SAXException, IOException
{
// TODO: make this configurable
boolean validate = false;
// get a xml reader instance:
SAXParserFactory factory = SAXParserFactory.newInstance();
log.info("RepositoryPersistor using SAXParserFactory : " + factory.getClass().getName());
if (validate)
{
factory.setValidating(true);
}
SAXParser p = factory.newSAXParser();
XMLReader reader = p.getXMLReader();
if (validate)
{
reader.setErrorHandler(new OJBErrorHandler());
}
Object result;
if (DescriptorRepository.class.equals(target))
{
// create an empty repository:
DescriptorRepository repository = new DescriptorRepository();
// create handler for building the repository structure
ContentHandler handler = new RepositoryXmlHandler(repository);
// tell parser to use our handler:
reader.setContentHandler(handler);
reader.parse(source);
result = repository;
}
else if (ConnectionRepository.class.equals(target))
{
// create an empty repository:
ConnectionRepository repository = new ConnectionRepository();
// create handler for building the repository structure
ContentHandler handler = new ConnectionDescriptorXmlHandler(repository);
// tell parser to use our handler:
reader.setContentHandler(handler);
reader.parse(source);
//LoggerFactory.getBootLogger().info("loading XML took " + (stop - start) + " msecs");
result = repository;
}
else
throw new MetadataException("Could not build a repository instance for '" + target +
"', using source " + source);
return result;
} | java | private Object readMetadataFromXML(InputSource source, Class target)
throws MalformedURLException, ParserConfigurationException, SAXException, IOException
{
// TODO: make this configurable
boolean validate = false;
// get a xml reader instance:
SAXParserFactory factory = SAXParserFactory.newInstance();
log.info("RepositoryPersistor using SAXParserFactory : " + factory.getClass().getName());
if (validate)
{
factory.setValidating(true);
}
SAXParser p = factory.newSAXParser();
XMLReader reader = p.getXMLReader();
if (validate)
{
reader.setErrorHandler(new OJBErrorHandler());
}
Object result;
if (DescriptorRepository.class.equals(target))
{
// create an empty repository:
DescriptorRepository repository = new DescriptorRepository();
// create handler for building the repository structure
ContentHandler handler = new RepositoryXmlHandler(repository);
// tell parser to use our handler:
reader.setContentHandler(handler);
reader.parse(source);
result = repository;
}
else if (ConnectionRepository.class.equals(target))
{
// create an empty repository:
ConnectionRepository repository = new ConnectionRepository();
// create handler for building the repository structure
ContentHandler handler = new ConnectionDescriptorXmlHandler(repository);
// tell parser to use our handler:
reader.setContentHandler(handler);
reader.parse(source);
//LoggerFactory.getBootLogger().info("loading XML took " + (stop - start) + " msecs");
result = repository;
}
else
throw new MetadataException("Could not build a repository instance for '" + target +
"', using source " + source);
return result;
} | [
"private",
"Object",
"readMetadataFromXML",
"(",
"InputSource",
"source",
",",
"Class",
"target",
")",
"throws",
"MalformedURLException",
",",
"ParserConfigurationException",
",",
"SAXException",
",",
"IOException",
"{",
"// TODO: make this configurable\r",
"boolean",
"validate",
"=",
"false",
";",
"// get a xml reader instance:\r",
"SAXParserFactory",
"factory",
"=",
"SAXParserFactory",
".",
"newInstance",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"RepositoryPersistor using SAXParserFactory : \"",
"+",
"factory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"validate",
")",
"{",
"factory",
".",
"setValidating",
"(",
"true",
")",
";",
"}",
"SAXParser",
"p",
"=",
"factory",
".",
"newSAXParser",
"(",
")",
";",
"XMLReader",
"reader",
"=",
"p",
".",
"getXMLReader",
"(",
")",
";",
"if",
"(",
"validate",
")",
"{",
"reader",
".",
"setErrorHandler",
"(",
"new",
"OJBErrorHandler",
"(",
")",
")",
";",
"}",
"Object",
"result",
";",
"if",
"(",
"DescriptorRepository",
".",
"class",
".",
"equals",
"(",
"target",
")",
")",
"{",
"// create an empty repository:\r",
"DescriptorRepository",
"repository",
"=",
"new",
"DescriptorRepository",
"(",
")",
";",
"// create handler for building the repository structure\r",
"ContentHandler",
"handler",
"=",
"new",
"RepositoryXmlHandler",
"(",
"repository",
")",
";",
"// tell parser to use our handler:\r",
"reader",
".",
"setContentHandler",
"(",
"handler",
")",
";",
"reader",
".",
"parse",
"(",
"source",
")",
";",
"result",
"=",
"repository",
";",
"}",
"else",
"if",
"(",
"ConnectionRepository",
".",
"class",
".",
"equals",
"(",
"target",
")",
")",
"{",
"// create an empty repository:\r",
"ConnectionRepository",
"repository",
"=",
"new",
"ConnectionRepository",
"(",
")",
";",
"// create handler for building the repository structure\r",
"ContentHandler",
"handler",
"=",
"new",
"ConnectionDescriptorXmlHandler",
"(",
"repository",
")",
";",
"// tell parser to use our handler:\r",
"reader",
".",
"setContentHandler",
"(",
"handler",
")",
";",
"reader",
".",
"parse",
"(",
"source",
")",
";",
"//LoggerFactory.getBootLogger().info(\"loading XML took \" + (stop - start) + \" msecs\");\r",
"result",
"=",
"repository",
";",
"}",
"else",
"throw",
"new",
"MetadataException",
"(",
"\"Could not build a repository instance for '\"",
"+",
"target",
"+",
"\"', using source \"",
"+",
"source",
")",
";",
"return",
"result",
";",
"}"
] | Read metadata by populating an instance of the target class
using SAXParser. | [
"Read",
"metadata",
"by",
"populating",
"an",
"instance",
"of",
"the",
"target",
"class",
"using",
"SAXParser",
"."
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/RepositoryPersistor.java#L297-L345 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.copy | public Criteria copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships)
{
Criteria copy = new Criteria();
copy.m_criteria = new Vector(this.m_criteria);
copy.m_negative = this.m_negative;
if (includeGroupBy)
{
copy.groupby = this.groupby;
}
if (includeOrderBy)
{
copy.orderby = this.orderby;
}
if (includePrefetchedRelationships)
{
copy.prefetchedRelationships = this.prefetchedRelationships;
}
return copy;
} | java | public Criteria copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships)
{
Criteria copy = new Criteria();
copy.m_criteria = new Vector(this.m_criteria);
copy.m_negative = this.m_negative;
if (includeGroupBy)
{
copy.groupby = this.groupby;
}
if (includeOrderBy)
{
copy.orderby = this.orderby;
}
if (includePrefetchedRelationships)
{
copy.prefetchedRelationships = this.prefetchedRelationships;
}
return copy;
} | [
"public",
"Criteria",
"copy",
"(",
"boolean",
"includeGroupBy",
",",
"boolean",
"includeOrderBy",
",",
"boolean",
"includePrefetchedRelationships",
")",
"{",
"Criteria",
"copy",
"=",
"new",
"Criteria",
"(",
")",
";",
"copy",
".",
"m_criteria",
"=",
"new",
"Vector",
"(",
"this",
".",
"m_criteria",
")",
";",
"copy",
".",
"m_negative",
"=",
"this",
".",
"m_negative",
";",
"if",
"(",
"includeGroupBy",
")",
"{",
"copy",
".",
"groupby",
"=",
"this",
".",
"groupby",
";",
"}",
"if",
"(",
"includeOrderBy",
")",
"{",
"copy",
".",
"orderby",
"=",
"this",
".",
"orderby",
";",
"}",
"if",
"(",
"includePrefetchedRelationships",
")",
"{",
"copy",
".",
"prefetchedRelationships",
"=",
"this",
".",
"prefetchedRelationships",
";",
"}",
"return",
"copy",
";",
"}"
] | make a copy of the criteria
@param includeGroupBy if true
@param includeOrderBy if ture
@param includePrefetchedRelationships if true
@return a copy of the criteria | [
"make",
"a",
"copy",
"of",
"the",
"criteria"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L124-L145 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.splitInCriteria | protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)
{
List result = new ArrayList();
Collection inCollection = new ArrayList();
if (values == null || values.isEmpty())
{
// OQL creates empty Criteria for late binding
result.add(buildInCriteria(attribute, negative, values));
}
else
{
Iterator iter = values.iterator();
while (iter.hasNext())
{
inCollection.add(iter.next());
if (inCollection.size() == inLimit || !iter.hasNext())
{
result.add(buildInCriteria(attribute, negative, inCollection));
inCollection = new ArrayList();
}
}
}
return result;
} | java | protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)
{
List result = new ArrayList();
Collection inCollection = new ArrayList();
if (values == null || values.isEmpty())
{
// OQL creates empty Criteria for late binding
result.add(buildInCriteria(attribute, negative, values));
}
else
{
Iterator iter = values.iterator();
while (iter.hasNext())
{
inCollection.add(iter.next());
if (inCollection.size() == inLimit || !iter.hasNext())
{
result.add(buildInCriteria(attribute, negative, inCollection));
inCollection = new ArrayList();
}
}
}
return result;
} | [
"protected",
"List",
"splitInCriteria",
"(",
"Object",
"attribute",
",",
"Collection",
"values",
",",
"boolean",
"negative",
",",
"int",
"inLimit",
")",
"{",
"List",
"result",
"=",
"new",
"ArrayList",
"(",
")",
";",
"Collection",
"inCollection",
"=",
"new",
"ArrayList",
"(",
")",
";",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"isEmpty",
"(",
")",
")",
"{",
"// OQL creates empty Criteria for late binding\r",
"result",
".",
"add",
"(",
"buildInCriteria",
"(",
"attribute",
",",
"negative",
",",
"values",
")",
")",
";",
"}",
"else",
"{",
"Iterator",
"iter",
"=",
"values",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"inCollection",
".",
"add",
"(",
"iter",
".",
"next",
"(",
")",
")",
";",
"if",
"(",
"inCollection",
".",
"size",
"(",
")",
"==",
"inLimit",
"||",
"!",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"result",
".",
"add",
"(",
"buildInCriteria",
"(",
"attribute",
",",
"negative",
",",
"inCollection",
")",
")",
";",
"inCollection",
"=",
"new",
"ArrayList",
"(",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Answer a List of InCriteria based on values, each InCriteria
contains only inLimit values
@param attribute
@param values
@param negative
@param inLimit the maximum number of values for IN (-1 for no limit)
@return List of InCriteria | [
"Answer",
"a",
"List",
"of",
"InCriteria",
"based",
"on",
"values",
"each",
"InCriteria",
"contains",
"only",
"inLimit",
"values"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L186-L211 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.getOrderby | List getOrderby()
{
List result = _getOrderby();
Iterator iter = getCriteria().iterator();
Object crit;
while (iter.hasNext())
{
crit = iter.next();
if (crit instanceof Criteria)
{
result.addAll(((Criteria) crit).getOrderby());
}
}
return result;
} | java | List getOrderby()
{
List result = _getOrderby();
Iterator iter = getCriteria().iterator();
Object crit;
while (iter.hasNext())
{
crit = iter.next();
if (crit instanceof Criteria)
{
result.addAll(((Criteria) crit).getOrderby());
}
}
return result;
} | [
"List",
"getOrderby",
"(",
")",
"{",
"List",
"result",
"=",
"_getOrderby",
"(",
")",
";",
"Iterator",
"iter",
"=",
"getCriteria",
"(",
")",
".",
"iterator",
"(",
")",
";",
"Object",
"crit",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"crit",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"crit",
"instanceof",
"Criteria",
")",
"{",
"result",
".",
"addAll",
"(",
"(",
"(",
"Criteria",
")",
"crit",
")",
".",
"getOrderby",
"(",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Answer the orderBy of all Criteria and Sub Criteria
the elements are of class Criteria.FieldHelper
@return List | [
"Answer",
"the",
"orderBy",
"of",
"all",
"Criteria",
"and",
"Sub",
"Criteria",
"the",
"elements",
"are",
"of",
"class",
"Criteria",
".",
"FieldHelper"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L618-L634 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.addColumnIsNull | public void addColumnIsNull(String column)
{
// PAW
//SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getAlias());
SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getUserAlias(column));
c.setTranslateAttribute(false);
addSelectionCriteria(c);
} | java | public void addColumnIsNull(String column)
{
// PAW
//SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getAlias());
SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getUserAlias(column));
c.setTranslateAttribute(false);
addSelectionCriteria(c);
} | [
"public",
"void",
"addColumnIsNull",
"(",
"String",
"column",
")",
"{",
"// PAW\r",
"//SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getAlias());\r",
"SelectionCriteria",
"c",
"=",
"ValueCriteria",
".",
"buildNullCriteria",
"(",
"column",
",",
"getUserAlias",
"(",
"column",
")",
")",
";",
"c",
".",
"setTranslateAttribute",
"(",
"false",
")",
";",
"addSelectionCriteria",
"(",
"c",
")",
";",
"}"
] | Adds is Null criteria,
customer_id is Null
The attribute will NOT be translated into column name
@param column The column name to be used without translation | [
"Adds",
"is",
"Null",
"criteria",
"customer_id",
"is",
"Null",
"The",
"attribute",
"will",
"NOT",
"be",
"translated",
"into",
"column",
"name"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L689-L696 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.addColumnNotNull | public void addColumnNotNull(String column)
{
// PAW
// SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getAlias());
SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getUserAlias(column));
c.setTranslateAttribute(false);
addSelectionCriteria(c);
} | java | public void addColumnNotNull(String column)
{
// PAW
// SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getAlias());
SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getUserAlias(column));
c.setTranslateAttribute(false);
addSelectionCriteria(c);
} | [
"public",
"void",
"addColumnNotNull",
"(",
"String",
"column",
")",
"{",
"// PAW\r",
"// SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getAlias());\r",
"SelectionCriteria",
"c",
"=",
"ValueCriteria",
".",
"buildNotNullCriteria",
"(",
"column",
",",
"getUserAlias",
"(",
"column",
")",
")",
";",
"c",
".",
"setTranslateAttribute",
"(",
"false",
")",
";",
"addSelectionCriteria",
"(",
"c",
")",
";",
"}"
] | Adds not Null criteria,
customer_id is not Null
The attribute will NOT be translated into column name
@param column The column name to be used without translation | [
"Adds",
"not",
"Null",
"criteria",
"customer_id",
"is",
"not",
"Null",
"The",
"attribute",
"will",
"NOT",
"be",
"translated",
"into",
"column",
"name"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L718-L725 | train |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.addBetween | public void addBetween(Object attribute, Object value1, Object value2)
{
// PAW
// addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getAlias()));
addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getUserAlias(attribute)));
} | java | public void addBetween(Object attribute, Object value1, Object value2)
{
// PAW
// addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getAlias()));
addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getUserAlias(attribute)));
} | [
"public",
"void",
"addBetween",
"(",
"Object",
"attribute",
",",
"Object",
"value1",
",",
"Object",
"value2",
")",
"{",
"// PAW\r",
"// addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getAlias()));\r",
"addSelectionCriteria",
"(",
"ValueCriteria",
".",
"buildBeweenCriteria",
"(",
"attribute",
",",
"value1",
",",
"value2",
",",
"getUserAlias",
"(",
"attribute",
")",
")",
")",
";",
"}"
] | Adds BETWEEN criteria,
customer_id between 1 and 10
@param attribute The field name to be used
@param value1 The lower boundary
@param value2 The upper boundary | [
"Adds",
"BETWEEN",
"criteria",
"customer_id",
"between",
"1",
"and",
"10"
] | 9a544372f67ce965f662cdc71609dd03683c8f04 | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L735-L740 | train |
Subsets and Splits