code
stringlengths 73
34.1k
| label
stringclasses 1
value |
---|---|
public void drawImage(Image img, Rectangle rect, Rectangle clipRect) {
drawImage(img, rect, clipRect, 1);
} | java |
public void drawImage(Image img, Rectangle rect, Rectangle clipRect, float opacity) {
try {
template.saveState();
// opacity
PdfGState state = new PdfGState();
state.setFillOpacity(opacity);
state.setBlendMode(PdfGState.BM_NORMAL);
template.setGState(state);
// clipping code
if (clipRect != null) {
template.rectangle(clipRect.getLeft() + origX, clipRect.getBottom() + origY, clipRect.getWidth(),
clipRect.getHeight());
template.clip();
template.newPath();
}
template.addImage(img, rect.getWidth(), 0, 0, rect.getHeight(), origX + rect.getLeft(), origY
+ rect.getBottom());
} catch (DocumentException e) {
log.warn("could not draw image", e);
} finally {
template.restoreState();
}
} | java |
public void drawGeometry(Geometry geometry, SymbolInfo symbol, Color fillColor, Color strokeColor, float lineWidth,
float[] dashArray, Rectangle clipRect) {
template.saveState();
// clipping code
if (clipRect != null) {
template.rectangle(clipRect.getLeft() + origX, clipRect.getBottom() + origY, clipRect.getWidth(), clipRect
.getHeight());
template.clip();
template.newPath();
}
setStroke(strokeColor, lineWidth, dashArray);
setFill(fillColor);
drawGeometry(geometry, symbol);
template.restoreState();
} | java |
public Rectangle toRelative(Rectangle rect) {
return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop()
- origY);
} | java |
public int getCount(Class target)
{
PersistenceBroker broker = ((HasBroker) odmg.currentTransaction()).getBroker();
int result = broker.getCount(new QueryByCriteria(target));
return result;
} | java |
public void setClasspath(Path classpath)
{
if (_classpath == null)
{
_classpath = classpath;
}
else
{
_classpath.append(classpath);
}
log("Verification classpath is "+ _classpath,
Project.MSG_VERBOSE);
} | java |
public void setClasspathRef(Reference r)
{
createClasspath().setRefid(r);
log("Verification classpath is "+ _classpath,
Project.MSG_VERBOSE);
} | java |
public Class getPersistentFieldClass()
{
if (m_persistenceClass == null)
{
Properties properties = new Properties();
try
{
this.logWarning("Loading properties file: " + getPropertiesFile());
properties.load(new FileInputStream(getPropertiesFile()));
}
catch (IOException e)
{
this.logWarning("Could not load properties file '" + getPropertiesFile()
+ "'. Using PersistentFieldDefaultImpl.");
e.printStackTrace();
}
try
{
String className = properties.getProperty("PersistentFieldClass");
m_persistenceClass = loadClass(className);
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
m_persistenceClass = PersistentFieldPrivilegedImpl.class;
}
logWarning("PersistentFieldClass: " + m_persistenceClass.toString());
}
return m_persistenceClass;
} | java |
@Override
public void visit(FeatureTypeStyle fts) {
FeatureTypeStyle copy = new FeatureTypeStyleImpl(
(FeatureTypeStyleImpl) fts);
Rule[] rules = fts.getRules();
int length = rules.length;
Rule[] rulesCopy = new Rule[length];
for (int i = 0; i < length; i++) {
if (rules[i] != null) {
rules[i].accept(this);
rulesCopy[i] = (Rule) pages.pop();
}
}
copy.setRules(rulesCopy);
if (fts.getTransformation() != null) {
copy.setTransformation(copy(fts.getTransformation()));
}
if (STRICT && !copy.equals(fts)) {
throw new IllegalStateException(
"Was unable to duplicate provided FeatureTypeStyle:" + fts);
}
pages.push(copy);
} | java |
@Override
public void visit(Rule rule) {
Rule copy = null;
Filter filterCopy = null;
if (rule.getFilter() != null) {
Filter filter = rule.getFilter();
filterCopy = copy(filter);
}
List<Symbolizer> symsCopy = new ArrayList<Symbolizer>();
for (Symbolizer sym : rule.symbolizers()) {
if (!skipSymbolizer(sym)) {
Symbolizer symCopy = copy(sym);
symsCopy.add(symCopy);
}
}
Graphic[] legendCopy = rule.getLegendGraphic();
for (int i = 0; i < legendCopy.length; i++) {
legendCopy[i] = copy(legendCopy[i]);
}
Description descCopy = rule.getDescription();
descCopy = copy(descCopy);
copy = sf.createRule();
copy.symbolizers().addAll(symsCopy);
copy.setDescription(descCopy);
copy.setLegendGraphic(legendCopy);
copy.setName(rule.getName());
copy.setFilter(filterCopy);
copy.setElseFilter(rule.isElseFilter());
copy.setMaxScaleDenominator(rule.getMaxScaleDenominator());
copy.setMinScaleDenominator(rule.getMinScaleDenominator());
if (STRICT && !copy.equals(rule)) {
throw new IllegalStateException(
"Was unable to duplicate provided Rule:" + rule);
}
pages.push(copy);
} | java |
private void registerSynchronization(TransactionImpl odmgTrans, Transaction transaction)
{
// todo only need for development
if (odmgTrans == null || transaction == null)
{
log.error("One of the given parameters was null --> cannot do synchronization!" +
" omdg transaction was null: " + (odmgTrans == null) +
", external transaction was null: " + (transaction == null));
return;
}
int status = -1; // default status.
try
{
status = transaction.getStatus();
if (status != Status.STATUS_ACTIVE)
{
throw new OJBRuntimeException(
"Transaction synchronization failed - wrong status of external container tx: " +
getStatusString(status));
}
}
catch (SystemException e)
{
throw new OJBRuntimeException("Can't read status of external tx", e);
}
try
{
//Sequence of the following method calls is significant
// 1. register the synchronization with the ODMG notion of a transaction.
transaction.registerSynchronization((J2EETransactionImpl) odmgTrans);
// 2. mark the ODMG transaction as being in a JTA Transaction
// Associate external transaction with the odmg transaction.
txRepository.set(new TxBuffer(odmgTrans, transaction));
}
catch (Exception e)
{
log.error("Cannot associate PersistenceBroker with running Transaction", e);
throw new OJBRuntimeException(
"Transaction synchronization failed - wrong status of external container tx", e);
}
} | java |
private TransactionManager getTransactionManager()
{
TransactionManager retval = null;
try
{
if (log.isDebugEnabled()) log.debug("getTransactionManager called");
retval = TransactionManagerFactoryFactory.instance().getTransactionManager();
}
catch (TransactionManagerFactoryException e)
{
log.warn("Exception trying to obtain TransactionManager from Factory", e);
e.printStackTrace();
}
return retval;
} | java |
public void abortExternalTx(TransactionImpl odmgTrans)
{
if (log.isDebugEnabled()) log.debug("abortExternTransaction was called");
if (odmgTrans == null) return;
TxBuffer buf = (TxBuffer) txRepository.get();
Transaction extTx = buf != null ? buf.getExternTx() : null;
try
{
if (extTx != null && extTx.getStatus() == Status.STATUS_ACTIVE)
{
if(log.isDebugEnabled())
{
log.debug("Set extern transaction to rollback");
}
extTx.setRollbackOnly();
}
}
catch (Exception ignore)
{
}
txRepository.set(null);
} | java |
public void check(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
{
ensureColumn(fieldDef, checkLevel);
ensureJdbcType(fieldDef, checkLevel);
ensureConversion(fieldDef, checkLevel);
ensureLength(fieldDef, checkLevel);
ensurePrecisionAndScale(fieldDef, checkLevel);
checkLocking(fieldDef, checkLevel);
checkSequenceName(fieldDef, checkLevel);
checkId(fieldDef, checkLevel);
if (fieldDef.isAnonymous())
{
checkAnonymous(fieldDef, checkLevel);
}
else
{
checkReadonlyAccessForNativePKs(fieldDef, checkLevel);
}
} | java |
private void ensureColumn(FieldDescriptorDef fieldDef, String checkLevel)
{
if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_COLUMN))
{
String javaname = fieldDef.getName();
if (fieldDef.isNested())
{
int pos = javaname.indexOf("::");
// we convert nested names ('_' for '::')
if (pos > 0)
{
StringBuffer newJavaname = new StringBuffer(javaname.substring(0, pos));
int lastPos = pos + 2;
do
{
pos = javaname.indexOf("::", lastPos);
newJavaname.append("_");
if (pos > 0)
{
newJavaname.append(javaname.substring(lastPos, pos));
lastPos = pos + 2;
}
else
{
newJavaname.append(javaname.substring(lastPos));
}
}
while (pos > 0);
javaname = newJavaname.toString();
}
}
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN, javaname);
}
} | java |
private void ensureConversion(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
// we issue a warning if we encounter a field with a java.util.Date java type without a conversion
if ("java.util.Date".equals(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JAVA_TYPE)) &&
!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_CONVERSION))
{
LogHelper.warn(true,
FieldDescriptorConstraints.class,
"ensureConversion",
"The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+
" of type java.util.Date is directly mapped to jdbc-type "+
fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE)+
". However, most JDBC drivers can't handle java.util.Date directly so you might want to "+
" use a conversion for converting it to a JDBC datatype like TIMESTAMP.");
}
String conversionClass = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_CONVERSION);
if (((conversionClass == null) || (conversionClass.length() == 0)) &&
fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION) &&
fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_JDBC_TYPE).equals(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE)))
{
conversionClass = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_CONVERSION, conversionClass);
}
// now checking
if (CHECKLEVEL_STRICT.equals(checkLevel) && (conversionClass != null) && (conversionClass.length() > 0))
{
InheritanceHelper helper = new InheritanceHelper();
try
{
if (!helper.isSameOrSubTypeOf(conversionClass, CONVERSION_INTERFACE))
{
throw new ConstraintException("The conversion class specified for field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" does not implement the necessary interface "+CONVERSION_INTERFACE);
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("The class "+ex.getMessage()+" hasn't been found on the classpath while checking the conversion class specified for field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName());
}
}
} | java |
private void ensureLength(FieldDescriptorDef fieldDef, String checkLevel)
{
if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_LENGTH))
{
String defaultLength = JdbcTypeHelper.getDefaultLengthFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
if (defaultLength != null)
{
LogHelper.warn(true,
FieldDescriptorConstraints.class,
"ensureLength",
"The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no length setting though its jdbc type requires it (in most databases); using default length of "+defaultLength);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_LENGTH, defaultLength);
}
}
} | java |
private void ensurePrecisionAndScale(FieldDescriptorDef fieldDef, String checkLevel)
{
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION, null);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, null);
if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_PRECISION))
{
String defaultPrecision = JdbcTypeHelper.getDefaultPrecisionFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
if (defaultPrecision != null)
{
LogHelper.warn(true,
FieldDescriptorConstraints.class,
"ensureLength",
"The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no precision setting though its jdbc type requires it (in most databases); using default precision of "+defaultPrecision);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION, defaultPrecision);
}
else if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_SCALE))
{
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION, "1");
}
}
if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_SCALE))
{
String defaultScale = JdbcTypeHelper.getDefaultScaleFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
if (defaultScale != null)
{
LogHelper.warn(true,
FieldDescriptorConstraints.class,
"ensureLength",
"The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no scale setting though its jdbc type requires it (in most databases); using default scale of "+defaultScale);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, defaultScale);
}
else if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_PRECISION) || fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION))
{
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, "0");
}
}
} | java |
private void checkLocking(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String jdbcType = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE);
if (!"TIMESTAMP".equals(jdbcType) && !"INTEGER".equals(jdbcType))
{
if (fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_LOCKING, false))
{
throw new ConstraintException("The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has locking set to true though it is not of TIMESTAMP or INTEGER type");
}
if (fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_UPDATE_LOCK, false))
{
throw new ConstraintException("The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has update-lock set to true though it is not of TIMESTAMP or INTEGER type");
}
}
} | java |
private void checkSequenceName(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String autoIncr = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_AUTOINCREMENT);
String seqName = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_SEQUENCE_NAME);
if ((seqName != null) && (seqName.length() > 0))
{
if (!"ojb".equals(autoIncr) && !"database".equals(autoIncr))
{
throw new ConstraintException("The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has sequence-name set though it's autoincrement value is not set to 'ojb'");
}
}
} | java |
private void checkId(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String id = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_ID);
if ((id != null) && (id.length() > 0))
{
try
{
Integer.parseInt(id);
}
catch (NumberFormatException ex)
{
throw new ConstraintException("The id attribute of field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" is not a valid number");
}
}
} | java |
private void checkReadonlyAccessForNativePKs(FieldDescriptorDef fieldDef, String checkLevel)
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String access = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_ACCESS);
String autoInc = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_AUTOINCREMENT);
if ("database".equals(autoInc) && !"readonly".equals(access))
{
LogHelper.warn(true,
FieldDescriptorConstraints.class,
"checkAccess",
"The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" is set to database auto-increment. Therefore the field's access is set to 'readonly'.");
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_ACCESS, "readonly");
}
} | java |
private void checkAnonymous(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String access = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_ACCESS);
if (!"anonymous".equals(access))
{
throw new ConstraintException("The access property of the field "+fieldDef.getName()+" defined in class "+fieldDef.getOwner().getName()+" cannot be changed");
}
if ((fieldDef.getName() == null) || (fieldDef.getName().length() == 0))
{
throw new ConstraintException("An anonymous field defined in class "+fieldDef.getOwner().getName()+" has no name");
}
} | java |
protected String sendRequestToDF(String df_service, Object msgContent) {
IDFComponentDescription[] receivers = getReceivers(df_service);
if (receivers.length > 0) {
IMessageEvent mevent = createMessageEvent("send_request");
mevent.getParameter(SFipa.CONTENT).setValue(msgContent);
for (int i = 0; i < receivers.length; i++) {
mevent.getParameterSet(SFipa.RECEIVERS).addValue(
receivers[i].getName());
logger.info("The receiver is " + receivers[i].getName());
}
sendMessage(mevent);
}
logger.info("Message sended to " + df_service + " to "
+ receivers.length + " receivers");
return ("Message sended to " + df_service);
} | java |
public Object copy(Object obj, PersistenceBroker broker)
throws ObjectCopyException
{
if (obj instanceof OjbCloneable)
{
try
{
return ((OjbCloneable) obj).ojbClone();
}
catch (Exception e)
{
throw new ObjectCopyException(e);
}
}
else
{
throw new ObjectCopyException("Object must implement OjbCloneable in order to use the"
+ " CloneableObjectCopyStrategy");
}
} | java |
public void addColumn(ColumnDef columnDef)
{
columnDef.setOwner(this);
_columns.put(columnDef.getName(), columnDef);
} | java |
public IndexDef getIndex(String name)
{
String realName = (name == null ? "" : name);
IndexDef def = null;
for (Iterator it = getIndices(); it.hasNext();)
{
def = (IndexDef)it.next();
if (def.getName().equals(realName))
{
return def;
}
}
return null;
} | java |
public void addForeignkey(String relationName, String remoteTable, List localColumns, List remoteColumns)
{
ForeignkeyDef foreignkeyDef = new ForeignkeyDef(relationName, remoteTable);
// the field arrays have the same length if we already checked the constraints
for (int idx = 0; idx < localColumns.size(); idx++)
{
foreignkeyDef.addColumnPair((String)localColumns.get(idx),
(String)remoteColumns.get(idx));
}
// we got to determine whether this foreignkey is already present
ForeignkeyDef def = null;
for (Iterator it = getForeignkeys(); it.hasNext();)
{
def = (ForeignkeyDef)it.next();
if (foreignkeyDef.equals(def))
{
return;
}
}
foreignkeyDef.setOwner(this);
_foreignkeys.add(foreignkeyDef);
} | java |
public boolean hasForeignkey(String name)
{
String realName = (name == null ? "" : name);
ForeignkeyDef def = null;
for (Iterator it = getForeignkeys(); it.hasNext();)
{
def = (ForeignkeyDef)it.next();
if (realName.equals(def.getName()))
{
return true;
}
}
return false;
} | java |
public ForeignkeyDef getForeignkey(String name, String tableName)
{
String realName = (name == null ? "" : name);
ForeignkeyDef def = null;
for (Iterator it = getForeignkeys(); it.hasNext();)
{
def = (ForeignkeyDef)it.next();
if (realName.equals(def.getName()) &&
def.getTableName().equals(tableName))
{
return def;
}
}
return null;
} | java |
protected static PropertyDescriptor findPropertyDescriptor(Class aClass, String aPropertyName)
{
BeanInfo info;
PropertyDescriptor[] pd;
PropertyDescriptor descriptor = null;
try
{
info = Introspector.getBeanInfo(aClass);
pd = info.getPropertyDescriptors();
for (int i = 0; i < pd.length; i++)
{
if (pd[i].getName().equals(aPropertyName))
{
descriptor = pd[i];
break;
}
}
if (descriptor == null)
{
/*
* Daren Drummond: Throw here so we are consistent
* with PersistentFieldDefaultImpl.
*/
throw new MetadataException("Can't find property " + aPropertyName + " in " + aClass.getName());
}
return descriptor;
}
catch (IntrospectionException ex)
{
/*
* Daren Drummond: Throw here so we are consistent
* with PersistentFieldDefaultImpl.
*/
throw new MetadataException("Can't find property " + aPropertyName + " in " + aClass.getName(), ex);
}
} | java |
private Expression getExpression(String expressionString) throws ParseException {
if (!expressionCache.containsKey(expressionString)) {
Expression expression;
expression = parser.parseExpression(expressionString);
expressionCache.put(expressionString, expression);
}
return expressionCache.get(expressionString);
} | java |
static final TimeBasedRollStrategy findRollStrategy(
final AppenderRollingProperties properties) {
if (properties.getDatePattern() == null) {
LogLog.error("null date pattern");
return ROLL_ERROR;
}
// Strip out quoted sections so that we may safely scan the undecorated
// pattern for characters that are meaningful to SimpleDateFormat.
final LocalizedDateFormatPatternHelper localizedDateFormatPatternHelper = new LocalizedDateFormatPatternHelper(
properties.getDatePatternLocale());
final String undecoratedDatePattern = localizedDateFormatPatternHelper
.excludeQuoted(properties.getDatePattern());
if (ROLL_EACH_MINUTE.isRequiredStrategy(localizedDateFormatPatternHelper,
undecoratedDatePattern)) {
return ROLL_EACH_MINUTE;
}
if (ROLL_EACH_HOUR.isRequiredStrategy(localizedDateFormatPatternHelper,
undecoratedDatePattern)) {
return ROLL_EACH_HOUR;
}
if (ROLL_EACH_HALF_DAY.isRequiredStrategy(localizedDateFormatPatternHelper,
undecoratedDatePattern)) {
return ROLL_EACH_HALF_DAY;
}
if (ROLL_EACH_DAY.isRequiredStrategy(localizedDateFormatPatternHelper,
undecoratedDatePattern)) {
return ROLL_EACH_DAY;
}
if (ROLL_EACH_WEEK.isRequiredStrategy(localizedDateFormatPatternHelper,
undecoratedDatePattern)) {
return ROLL_EACH_WEEK;
}
if (ROLL_EACH_MONTH.isRequiredStrategy(localizedDateFormatPatternHelper,
undecoratedDatePattern)) {
return ROLL_EACH_MONTH;
}
return ROLL_ERROR;
} | java |
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
Main.getProperties().setProperty(Main.PROPERTY_MAINFRAME_HEIGHT, "" + this.getHeight());
Main.getProperties().setProperty(Main.PROPERTY_MAINFRAME_WIDTH, "" + this.getWidth());
Main.getProperties().setProperty(Main.PROPERTY_MAINFRAME_POSX, "" + this.getBounds().x);
Main.getProperties().setProperty(Main.PROPERTY_MAINFRAME_POSY, "" + this.getBounds().y);
Main.getProperties().storeProperties("");
System.exit(0);
} | java |
public String getPrototypeName() {
String name = getClass().getName();
if (name.startsWith(ORG_GEOMAJAS)) {
name = name.substring(ORG_GEOMAJAS.length());
}
name = name.replace(".dto.", ".impl.");
return name.substring(0, name.length() - 4) + "Impl";
} | java |
@Programmatic
public <T> Blob toExcelPivot(
final List<T> domainObjects,
final Class<T> cls,
final String fileName) throws ExcelService.Exception {
return toExcelPivot(domainObjects, cls, null, fileName);
} | java |
protected void checkProxyPrefetchingLimit(DefBase def, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
if (def.hasProperty(PropertyHelper.OJB_PROPERTY_PROXY_PREFETCHING_LIMIT))
{
if (!def.hasProperty(PropertyHelper.OJB_PROPERTY_PROXY))
{
if (def instanceof ClassDescriptorDef)
{
LogHelper.warn(true,
ConstraintsBase.class,
"checkProxyPrefetchingLimit",
"The class "+def.getName()+" has a proxy-prefetching-limit property but no proxy property");
}
else
{
LogHelper.warn(true,
ConstraintsBase.class,
"checkProxyPrefetchingLimit",
"The feature "+def.getName()+" in class "+def.getOwner().getName()+" has a proxy-prefetching-limit property but no proxy property");
}
}
String propValue = def.getProperty(PropertyHelper.OJB_PROPERTY_PROXY_PREFETCHING_LIMIT);
try
{
int value = Integer.parseInt(propValue);
if (value < 0)
{
if (def instanceof ClassDescriptorDef)
{
throw new ConstraintException("The proxy-prefetching-limit value of class "+def.getName()+" must be a non-negative number");
}
else
{
throw new ConstraintException("The proxy-prefetching-limit value of the feature "+def.getName()+" in class "+def.getOwner().getName()+" must be a non-negative number");
}
}
}
catch (NumberFormatException ex)
{
if (def instanceof ClassDescriptorDef)
{
throw new ConstraintException("The proxy-prefetching-limit value of the class "+def.getName()+" is not a number");
}
else
{
throw new ConstraintException("The proxy-prefetching-limit value of the feature "+def.getName()+" in class "+def.getOwner().getName()+" is not a number");
}
}
}
} | java |
public boolean shouldCache(String requestUri) {
String uri = requestUri.toLowerCase();
return checkContains(uri, cacheIdentifiers) || checkSuffixes(uri, cacheSuffixes);
} | java |
public boolean shouldNotCache(String requestUri) {
String uri = requestUri.toLowerCase();
return checkContains(uri, noCacheIdentifiers) || checkSuffixes(uri, noCacheSuffixes);
} | java |
public boolean shouldCompress(String requestUri) {
String uri = requestUri.toLowerCase();
return checkSuffixes(uri, zipSuffixes);
} | java |
public boolean checkContains(String uri, String[] patterns) {
for (String pattern : patterns) {
if (pattern.length() > 0) {
if (uri.contains(pattern)) {
return true;
}
}
}
return false;
} | java |
public boolean checkSuffixes(String uri, String[] patterns) {
for (String pattern : patterns) {
if (pattern.length() > 0) {
if (uri.endsWith(pattern)) {
return true;
}
}
}
return false;
} | java |
public boolean checkPrefixes(String uri, String[] patterns) {
for (String pattern : patterns) {
if (pattern.length() > 0) {
if (uri.startsWith(pattern)) {
return true;
}
}
}
return false;
} | java |
@Api
public static void configureNoCaching(HttpServletResponse response) {
// HTTP 1.0 header:
response.setHeader(HTTP_EXPIRES_HEADER, HTTP_EXPIRES_HEADER_NOCACHE_VALUE);
response.setHeader(HTTP_CACHE_PRAGMA, HTTP_CACHE_PRAGMA_VALUE);
// HTTP 1.1 header:
response.setHeader(HTTP_CACHE_CONTROL_HEADER, HTTP_CACHE_CONTROL_HEADER_NOCACHE_VALUE);
} | java |
public static Context getContext()
{
if (ctx == null)
{
try
{
setContext(null);
}
catch (Exception e)
{
log.error("Cannot instantiate the InitialContext", e);
throw new OJBRuntimeException(e);
}
}
return ctx;
} | java |
public static Object lookup(String jndiName)
{
if(log.isDebugEnabled()) log.debug("lookup("+jndiName+") was called");
try
{
return getContext().lookup(jndiName);
}
catch (NamingException e)
{
throw new OJBRuntimeException("Lookup failed for: " + jndiName, e);
}
catch(OJBRuntimeException e)
{
throw e;
}
} | java |
public Authentication getAuthentication(String token) {
if (null != token) {
TokenContainer container = tokens.get(token);
if (null != container) {
if (container.isValid()) {
return container.getAuthentication();
} else {
logout(token);
}
}
}
return null;
} | java |
public String login(Authentication authentication) {
String token = getToken();
return login(token, authentication);
} | java |
public String login(String token, Authentication authentication) {
if (null == token) {
return login(authentication);
}
tokens.put(token, new TokenContainer(authentication));
return token;
} | java |
public boolean getBooleanProperty(String name, boolean defaultValue)
{
return PropertyHelper.toBoolean(_properties.getProperty(name), defaultValue);
} | java |
public SimpleFeatureSource getFeatureSource() throws LayerException {
try {
if (dataStore instanceof WFSDataStore) {
return dataStore.getFeatureSource(featureSourceName.replace(":", "_"));
} else {
return dataStore.getFeatureSource(featureSourceName);
}
} catch (IOException e) {
throw new LayerException(e, ExceptionCode.FEATURE_MODEL_PROBLEM,
"Cannot find feature source " + featureSourceName);
} catch (NullPointerException e) {
throw new LayerException(e, ExceptionCode.FEATURE_MODEL_PROBLEM,
"Cannot find feature source " + featureSourceName);
}
} | java |
public void setAttributes(Object feature, Map<String, Attribute> attributes) throws LayerException {
for (Map.Entry<String, Attribute> entry : attributes.entrySet()) {
String name = entry.getKey();
if (!name.equals(getGeometryAttributeName())) {
asFeature(feature).setAttribute(name, entry.getValue());
}
}
} | java |
private Object getAttributeRecursively(Object feature, String name) throws LayerException {
if (feature == null) {
return null;
}
// Split up properties: the first and the rest.
String[] properties = name.split(SEPARATOR_REGEXP, 2);
Object tempFeature;
// If the first property is the identifier:
if (properties[0].equals(getFeatureInfo().getIdentifier().getName())) {
tempFeature = getId(feature);
} else {
Entity entity = entityMapper.asEntity(feature);
HibernateEntity child = (HibernateEntity) entity.getChild(properties[0]);
tempFeature = child == null ? null : child.getObject();
}
// Detect if the first property is a collection (one-to-many):
if (tempFeature instanceof Collection<?>) {
Collection<?> features = (Collection<?>) tempFeature;
Object[] values = new Object[features.size()];
int count = 0;
for (Object value : features) {
if (properties.length == 1) {
values[count++] = value;
} else {
values[count++] = getAttributeRecursively(value, properties[1]);
}
}
return values;
} else { // Else first property is not a collection (one-to-many):
if (properties.length == 1 || tempFeature == null) {
return tempFeature;
} else {
return getAttributeRecursively(tempFeature, properties[1]);
}
}
} | java |
public boolean shouldBeInReport(final DbDependency dependency) {
if(dependency == null){
return false;
}
if(dependency.getTarget() == null){
return false;
}
if(corporateFilter != null){
if(!decorator.getShowThirdparty() && !corporateFilter.filter(dependency)){
return false;
}
if(!decorator.getShowCorporate() && corporateFilter.filter(dependency)){
return false;
}
}
if(!scopeHandler.filter(dependency)){
return false;
}
return true;
} | java |
public Map<String, Object> getArtifactFieldsFilters() {
final Map<String, Object> params = new HashMap<String, Object>();
for(final Filter filter: filters){
params.putAll(filter.artifactFilterFields());
}
return params;
} | java |
public Map<String, Object> getModuleFieldsFilters() {
final Map<String, Object> params = new HashMap<String, Object>();
for(final Filter filter: filters){
params.putAll(filter.moduleFilterFields());
}
return params;
} | java |
private DBHandling createDBHandling() throws BuildException
{
if ((_handling == null) || (_handling.length() == 0))
{
throw new BuildException("No handling specified");
}
try
{
String className = "org.apache.ojb.broker.platforms."+
Character.toTitleCase(_handling.charAt(0))+_handling.substring(1)+
"DBHandling";
Class handlingClass = ClassHelper.getClass(className);
return (DBHandling)handlingClass.newInstance();
}
catch (Exception ex)
{
throw new BuildException("Invalid handling '"+_handling+"' specified");
}
} | java |
private void addIncludes(DBHandling handling, FileSet fileSet) throws BuildException
{
DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
StringBuffer includes = new StringBuffer();
for (int idx = 0; idx < files.length; idx++)
{
if (idx > 0)
{
includes.append(",");
}
includes.append(files[idx]);
}
try
{
handling.addDBDefinitionFiles(fileSet.getDir(getProject()).getAbsolutePath(), includes.toString());
}
catch (IOException ex)
{
throw new BuildException(ex);
}
} | java |
public void setModel(Database databaseModel, DescriptorRepository objModel)
{
_dbModel = databaseModel;
_preparedModel = new PreparedModel(objModel, databaseModel);
} | java |
public void getDataDTD(Writer output) throws DataTaskException
{
try
{
output.write("<!ELEMENT dataset (\n");
for (Iterator it = _preparedModel.getElementNames(); it.hasNext();)
{
String elementName = (String)it.next();
output.write(" ");
output.write(elementName);
output.write("*");
output.write(it.hasNext() ? " |\n" : "\n");
}
output.write(")>\n<!ATTLIST dataset\n name CDATA #REQUIRED\n>\n");
for (Iterator it = _preparedModel.getElementNames(); it.hasNext();)
{
String elementName = (String)it.next();
List classDescs = _preparedModel.getClassDescriptorsMappingTo(elementName);
if (classDescs == null)
{
output.write("\n<!-- Indirection table");
}
else
{
output.write("\n<!-- Mapped to : ");
for (Iterator classDescIt = classDescs.iterator(); classDescIt.hasNext();)
{
ClassDescriptor classDesc = (ClassDescriptor)classDescIt.next();
output.write(classDesc.getClassNameOfObject());
if (classDescIt.hasNext())
{
output.write("\n ");
}
}
}
output.write(" -->\n<!ELEMENT ");
output.write(elementName);
output.write(" EMPTY>\n<!ATTLIST ");
output.write(elementName);
output.write("\n");
for (Iterator attrIt = _preparedModel.getAttributeNames(elementName); attrIt.hasNext();)
{
String attrName = (String)attrIt.next();
output.write(" ");
output.write(attrName);
output.write(" CDATA #");
output.write(_preparedModel.isRequired(elementName, attrName) ? "REQUIRED" : "IMPLIED");
output.write("\n");
}
output.write(">\n");
}
}
catch (IOException ex)
{
throw new DataTaskException(ex);
}
} | java |
public static Object instantiate(Class clazz) throws InstantiationException
{
Object result = null;
try
{
result = ClassHelper.newInstance(clazz);
}
catch(IllegalAccessException e)
{
try
{
result = ClassHelper.newInstance(clazz, true);
}
catch(Exception e1)
{
throw new ClassNotPersistenceCapableException("Can't instantiate class '"
+ (clazz != null ? clazz.getName() : "null")
+ "', message was: " + e1.getMessage() + ")", e1);
}
}
return result;
} | java |
public static Object instantiate(Constructor constructor) throws InstantiationException
{
if(constructor == null)
{
throw new ClassNotPersistenceCapableException(
"A zero argument constructor was not provided!");
}
Object result = null;
try
{
result = constructor.newInstance(NO_ARGS);
}
catch(InstantiationException e)
{
throw e;
}
catch(Exception e)
{
throw new ClassNotPersistenceCapableException("Can't instantiate class '"
+ (constructor != null ? constructor.getDeclaringClass().getName() : "null")
+ "' with given constructor: " + e.getMessage(), e);
}
return result;
} | java |
public void synchTransaction(SimpleFeatureStore featureStore) {
// check if transaction is active, otherwise do nothing (auto-commit mode)
if (TransactionSynchronizationManager.isActualTransactionActive()) {
DataAccess<SimpleFeatureType, SimpleFeature> dataStore = featureStore.getDataStore();
if (!transactions.containsKey(dataStore)) {
Transaction transaction = null;
if (dataStore instanceof JDBCDataStore) {
JDBCDataStore jdbcDataStore = (JDBCDataStore) dataStore;
transaction = jdbcDataStore.buildTransaction(DataSourceUtils
.getConnection(jdbcDataStore.getDataSource()));
} else {
transaction = new DefaultTransaction();
}
transactions.put(dataStore, transaction);
}
featureStore.setTransaction(transactions.get(dataStore));
}
} | java |
@PostConstruct
protected void buildCopyrightMap() {
if (null == declaredPlugins) {
return;
}
// go over all plug-ins, adding copyright info, avoiding duplicates (on object key)
for (PluginInfo plugin : declaredPlugins.values()) {
for (CopyrightInfo copyright : plugin.getCopyrightInfo()) {
String key = copyright.getKey();
String msg = copyright.getKey() + ": " + copyright.getCopyright() + " : licensed as " +
copyright.getLicenseName() + ", see " + copyright.getLicenseUrl();
if (null != copyright.getSourceUrl()) {
msg += " source " + copyright.getSourceUrl();
}
if (!copyrightMap.containsKey(key)) {
log.info(msg);
copyrightMap.put(key, copyright);
}
}
}
} | java |
public void storeIfNew(final DbArtifact fromClient) {
final DbArtifact existing = repositoryHandler.getArtifact(fromClient.getGavc());
if(existing != null){
existing.setLicenses(fromClient.getLicenses());
store(existing);
}
if(existing == null){
store(fromClient);
}
} | java |
public void addLicense(final String gavc, final String licenseId) {
final DbArtifact dbArtifact = getArtifact(gavc);
// Try to find an existing license that match the new one
final LicenseHandler licenseHandler = new LicenseHandler(repositoryHandler);
final DbLicense license = licenseHandler.resolve(licenseId);
// If there is no existing license that match this one let's use the provided value but
// only if the artifact has no license yet. Otherwise it could mean that users has already
// identify the license manually.
if(license == null){
if(dbArtifact.getLicenses().isEmpty()){
LOG.warn("Add reference to a non existing license called " + licenseId + " in artifact " + dbArtifact.getGavc());
repositoryHandler.addLicenseToArtifact(dbArtifact, licenseId);
}
}
// Add only if the license is not already referenced
else if(!dbArtifact.getLicenses().contains(license.getName())){
repositoryHandler.addLicenseToArtifact(dbArtifact, license.getName());
}
} | java |
public List<String> getArtifactVersions(final String gavc) {
final DbArtifact artifact = getArtifact(gavc);
return repositoryHandler.getArtifactVersions(artifact);
} | java |
public String getArtifactLastVersion(final String gavc) {
final List<String> versions = getArtifactVersions(gavc);
final VersionsHandler versionHandler = new VersionsHandler(repositoryHandler);
final String viaCompare = versionHandler.getLastVersion(versions);
if (viaCompare != null) {
return viaCompare;
}
//
// These versions cannot be compared
// Let's use the Collection.max() method by default, so goingo for a fallback
// mechanism.
//
LOG.info("The versions cannot be compared");
return Collections.max(versions);
} | java |
public DbArtifact getArtifact(final String gavc) {
final DbArtifact artifact = repositoryHandler.getArtifact(gavc);
if(artifact == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Artifact " + gavc + " does not exist.").build());
}
return artifact;
} | java |
public DbOrganization getOrganization(final DbArtifact dbArtifact) {
final DbModule module = getModule(dbArtifact);
if(module == null || module.getOrganization() == null){
return null;
}
return repositoryHandler.getOrganization(module.getOrganization());
} | java |
public void updateDownLoadUrl(final String gavc, final String downLoadUrl) {
final DbArtifact artifact = getArtifact(gavc);
repositoryHandler.updateDownloadUrl(artifact, downLoadUrl);
} | java |
public void updateProvider(final String gavc, final String provider) {
final DbArtifact artifact = getArtifact(gavc);
repositoryHandler.updateProvider(artifact, provider);
} | java |
public List<DbModule> getAncestors(final String gavc, final FiltersHolder filters) {
final DbArtifact dbArtifact = getArtifact(gavc);
return repositoryHandler.getAncestors(dbArtifact, filters);
} | java |
public List<DbLicense> getArtifactLicenses(final String gavc, final FiltersHolder filters) {
final DbArtifact artifact = getArtifact(gavc);
final List<DbLicense> licenses = new ArrayList<>();
for(final String name: artifact.getLicenses()){
final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(name);
// Here is a license to identify
if(matchingLicenses.isEmpty()){
final DbLicense notIdentifiedLicense = new DbLicense();
notIdentifiedLicense.setName(name);
licenses.add(notIdentifiedLicense);
} else {
matchingLicenses.stream()
.filter(filters::shouldBeInReport)
.forEach(licenses::add);
}
}
return licenses;
} | java |
public void removeLicenseFromArtifact(final String gavc, final String licenseId) {
final DbArtifact dbArtifact = getArtifact(gavc);
//
// The artifact may not have the exact string associated with it, but rather one
// matching license regexp expression.
//
repositoryHandler.removeLicenseFromArtifact(dbArtifact, licenseId, licenseMatcher);
} | java |
public String getModuleJenkinsJobInfo(final DbArtifact dbArtifact) {
final DbModule module = getModule(dbArtifact);
if(module == null){
return "";
}
final String jenkinsJobUrl = module.getBuildInfo().get("jenkins-job-url");
if(jenkinsJobUrl == null){
return "";
}
return jenkinsJobUrl;
} | java |
public static String getDefaultJdbcTypeFor(String javaType)
{
return _jdbcMappings.containsKey(javaType) ? (String)_jdbcMappings.get(javaType) : JDBC_DEFAULT_TYPE;
} | java |
public static String getDefaultConversionFor(String javaType)
{
return _jdbcConversions.containsKey(javaType) ? (String)_jdbcConversions.get(javaType) : null;
} | java |
protected Query buildMtoNImplementorQuery(Collection ids)
{
String[] indFkCols = getFksToThisClass();
String[] indItemFkCols = getFksToItemClass();
FieldDescriptor[] pkFields = getOwnerClassDescriptor().getPkFields();
FieldDescriptor[] itemPkFields = getItemClassDescriptor().getPkFields();
String[] cols = new String[indFkCols.length + indItemFkCols.length];
int[] jdbcTypes = new int[indFkCols.length + indItemFkCols.length];
// concatenate the columns[]
System.arraycopy(indFkCols, 0, cols, 0, indFkCols.length);
System.arraycopy(indItemFkCols, 0, cols, indFkCols.length, indItemFkCols.length);
Criteria crit = buildPrefetchCriteria(ids, indFkCols, indItemFkCols, itemPkFields);
// determine the jdbcTypes of the pks
for (int i = 0; i < pkFields.length; i++)
{
jdbcTypes[i] = pkFields[i].getJdbcType().getType();
}
for (int i = 0; i < itemPkFields.length; i++)
{
jdbcTypes[pkFields.length + i] = itemPkFields[i].getJdbcType().getType();
}
ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria(getItemClassDescriptor().getClassOfObject(), cols,
crit, false);
q.setIndirectionTable(getCollectionDescriptor().getIndirectionTable());
q.setJdbcTypes(jdbcTypes);
CollectionDescriptor cds = getCollectionDescriptor();
//check if collection must be ordered
if (!cds.getOrderBy().isEmpty())
{
Iterator iter = cds.getOrderBy().iterator();
while (iter.hasNext())
{
q.addOrderBy((FieldHelper) iter.next());
}
}
return q;
} | java |
private String[] getFksToThisClass()
{
String indTable = getCollectionDescriptor().getIndirectionTable();
String[] fks = getCollectionDescriptor().getFksToThisClass();
String[] result = new String[fks.length];
for (int i = 0; i < result.length; i++)
{
result[i] = indTable + "." + fks[i];
}
return result;
} | java |
private FieldConversion[] getPkFieldConversion(ClassDescriptor cld)
{
FieldDescriptor[] pks = cld.getPkFields();
FieldConversion[] fc = new FieldConversion[pks.length];
for (int i= 0; i < pks.length; i++)
{
fc[i] = pks[i].getFieldConversion();
}
return fc;
} | java |
private Object[] convert(FieldConversion[] fcs, Object[] values)
{
Object[] convertedValues = new Object[values.length];
for (int i= 0; i < values.length; i++)
{
convertedValues[i] = fcs[i].sqlToJava(values[i]);
}
return convertedValues;
} | java |
public void displayUseCases()
{
System.out.println();
for (int i = 0; i < useCases.size(); i++)
{
System.out.println("[" + i + "] " + ((UseCase) useCases.get(i)).getDescription());
}
} | java |
public void run()
{
System.out.println(AsciiSplash.getSplashArt());
System.out.println("Welcome to the OJB PB tutorial application");
System.out.println();
// never stop (there is a special use case to quit the application)
while (true)
{
try
{
// select a use case and perform it
UseCase uc = selectUseCase();
uc.apply();
}
catch (Throwable t)
{
broker.close();
System.out.println(t.getMessage());
}
}
} | java |
public UseCase selectUseCase()
{
displayUseCases();
System.out.println("type in number to select a use case");
String in = readLine();
int index = Integer.parseInt(in);
return (UseCase) useCases.get(index);
} | java |
public int getJdbcType(String ojbType) throws SQLException
{
int result;
if(ojbType == null) ojbType = "";
ojbType = ojbType.toLowerCase();
if (ojbType.equals("bit"))
result = Types.BIT;
else if (ojbType.equals("tinyint"))
result = Types.TINYINT;
else if (ojbType.equals("smallint"))
result = Types.SMALLINT;
else if (ojbType.equals("integer"))
result = Types.INTEGER;
else if (ojbType.equals("bigint"))
result = Types.BIGINT;
else if (ojbType.equals("float"))
result = Types.FLOAT;
else if (ojbType.equals("real"))
result = Types.REAL;
else if (ojbType.equals("double"))
result = Types.DOUBLE;
else if (ojbType.equals("numeric"))
result = Types.NUMERIC;
else if (ojbType.equals("decimal"))
result = Types.DECIMAL;
else if (ojbType.equals("char"))
result = Types.CHAR;
else if (ojbType.equals("varchar"))
result = Types.VARCHAR;
else if (ojbType.equals("longvarchar"))
result = Types.LONGVARCHAR;
else if (ojbType.equals("date"))
result = Types.DATE;
else if (ojbType.equals("time"))
result = Types.TIME;
else if (ojbType.equals("timestamp"))
result = Types.TIMESTAMP;
else if (ojbType.equals("binary"))
result = Types.BINARY;
else if (ojbType.equals("varbinary"))
result = Types.VARBINARY;
else if (ojbType.equals("longvarbinary"))
result = Types.LONGVARBINARY;
else if (ojbType.equals("clob"))
result = Types.CLOB;
else if (ojbType.equals("blob"))
result = Types.BLOB;
else
throw new SQLException(
"The type '"+ ojbType + "' is not a valid jdbc type.");
return result;
} | java |
public void addRoute(String path, Class<? extends Actor> actorClass) throws RouteAlreadyMappedException {
addRoute(new Route(path, false), actorClass);
} | java |
public void addRegexRoute(String urlPattern, Class<? extends Actor> actorClass) throws RouteAlreadyMappedException {
addRoute(new Route(urlPattern, true), actorClass);
} | java |
public void setObjectForStatement(PreparedStatement ps, int index,
Object value, int sqlType) throws SQLException
{
if (sqlType == Types.TINYINT)
{
ps.setByte(index, ((Byte) value).byteValue());
}
else
{
super.setObjectForStatement(ps, index, value, sqlType);
}
} | java |
public Collection getAllObjects(Class target)
{
PersistenceBroker broker = getBroker();
Collection result;
try
{
Query q = new QueryByCriteria(target);
result = broker.getCollectionByQuery(q);
}
finally
{
if (broker != null) broker.close();
}
return result;
} | java |
public void deleteObject(Object object)
{
PersistenceBroker broker = null;
try
{
broker = getBroker();
broker.delete(object);
}
finally
{
if (broker != null) broker.close();
}
} | java |
public void bind(Object object, String name)
throws ObjectNameNotUniqueException
{
/**
* Is DB open? ODMG 3.0 says it has to be to call bind.
*/
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open. Must have an open DB to call bind.");
}
/**
* Is Tx open? ODMG 3.0 says it has to be to call bind.
*/
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("Tx is not open. Must have an open TX to call bind.");
}
tx.getNamedRootsMap().bind(object, name);
} | java |
public Object lookup(String name) throws ObjectNameNotFoundException
{
/**
* Is DB open? ODMG 3.0 says it has to be to call bind.
*/
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open. Must have an open DB to call lookup");
}
/**
* Is Tx open? ODMG 3.0 says it has to be to call bind.
*/
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("Tx is not open. Must have an open TX to call lookup.");
}
return tx.getNamedRootsMap().lookup(name);
} | java |
public void unbind(String name) throws ObjectNameNotFoundException
{
/**
* Is DB open? ODMG 3.0 says it has to be to call unbind.
*/
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open. Must have an open DB to call unbind");
}
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("Tx is not open. Must have an open TX to call lookup.");
}
tx.getNamedRootsMap().unbind(name);
} | java |
public void deletePersistent(Object object)
{
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open");
}
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("No transaction in progress, cannot delete persistent");
}
RuntimeObject rt = new RuntimeObject(object, tx);
tx.deletePersistent(rt);
// tx.moveToLastInOrderList(rt.getIdentity());
} | java |
protected void appendWhereClause(StringBuffer stmt, Object[] columns)
{
stmt.append(" WHERE ");
for (int i = 0; i < columns.length; i++)
{
if (i > 0)
{
stmt.append(" AND ");
}
stmt.append(columns[i]);
stmt.append("=?");
}
} | java |
private void logState(final FileRollEvent fileRollEvent) {
// if (ApplicationState.isApplicationStateEnabled()) {
synchronized (this) {
final Collection<ApplicationState.ApplicationStateMessage> entries = ApplicationState.getAppStateEntries();
for (ApplicationState.ApplicationStateMessage entry : entries) {
Level level = ApplicationState.getLog4jLevel(entry.getLevel());
if(level.isGreaterOrEqual(ApplicationState.LOGGER.getEffectiveLevel())) {
final org.apache.log4j.spi.LoggingEvent loggingEvent = new org.apache.log4j.spi.LoggingEvent(ApplicationState.FQCN, ApplicationState.LOGGER, level, entry.getMessage(), null);
//Save the current layout before changing it to the original (relevant for marker cases when the layout was changed)
Layout current=fileRollEvent.getSource().getLayout();
//fileRollEvent.getSource().activeOriginalLayout();
String flowContext = (String) MDC.get("flowCtxt");
MDC.remove("flowCtxt");
//Write applicationState:
if(fileRollEvent.getSource().isAddApplicationState() && fileRollEvent.getSource().getFile().endsWith("log")){
fileRollEvent.dispatchToAppender(loggingEvent);
}
//Set current again.
fileRollEvent.getSource().setLayout(current);
if (flowContext != null) {
MDC.put("flowCtxt", flowContext);
}
}
}
}
// }
} | java |
public void setBooleanAttribute(String name, Boolean value) {
ensureValue();
Attribute attribute = new BooleanAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java |
public void setFloatAttribute(String name, Float value) {
ensureValue();
Attribute attribute = new FloatAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java |
public void setIntegerAttribute(String name, Integer value) {
ensureValue();
Attribute attribute = new IntegerAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.