code
stringlengths 73
34.1k
| label
stringclasses 1
value |
---|---|
public void addNotBetween(Object attribute, Object value1, Object value2)
{
// PAW
// addSelectionCriteria(ValueCriteria.buildNotBeweenCriteria(attribute, value1, value2, getAlias()));
addSelectionCriteria(ValueCriteria.buildNotBeweenCriteria(attribute, value1, value2, getUserAlias(attribute)));
} | java |
public void addIn(Object attribute, Query subQuery)
{
// PAW
// addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery, getAlias()));
addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery, getUserAlias(attribute)));
} | java |
public void addNotIn(String attribute, Query subQuery)
{
// PAW
// addSelectionCriteria(ValueCriteria.buildNotInCriteria(attribute, subQuery, getAlias()));
addSelectionCriteria(ValueCriteria.buildNotInCriteria(attribute, subQuery, getUserAlias(attribute)));
} | java |
List getGroupby()
{
List result = _getGroupby();
Iterator iter = getCriteria().iterator();
Object crit;
while (iter.hasNext())
{
crit = iter.next();
if (crit instanceof Criteria)
{
result.addAll(((Criteria) crit).getGroupby());
}
}
return result;
} | java |
public void addGroupBy(String[] fieldNames)
{
for (int i = 0; i < fieldNames.length; i++)
{
addGroupBy(fieldNames[i]);
}
} | java |
private static int getSqlInLimit()
{
try
{
PersistenceBrokerConfiguration config = (PersistenceBrokerConfiguration) PersistenceBrokerFactory
.getConfigurator().getConfigurationFor(null);
return config.getSqlInLimit();
}
catch (ConfigurationException e)
{
return 200;
}
} | java |
private UserAlias getUserAlias(Object attribute)
{
if (m_userAlias != null)
{
return m_userAlias;
}
if (!(attribute instanceof String))
{
return null;
}
if (m_alias == null)
{
return null;
}
if (m_aliasPath == null)
{
boolean allPathsAliased = true;
return new UserAlias(m_alias, (String)attribute, allPathsAliased);
}
return new UserAlias(m_alias, (String)attribute, m_aliasPath);
} | java |
public void setAlias(String alias)
{
if (alias == null || alias.trim().equals(""))
{
m_alias = null;
}
else
{
m_alias = alias;
}
// propagate to SelectionCriteria,not to Criteria
for (int i = 0; i < m_criteria.size(); i++)
{
if (!(m_criteria.elementAt(i) instanceof Criteria))
{
((SelectionCriteria) m_criteria.elementAt(i)).setAlias(m_alias);
}
}
} | java |
public void setAlias(UserAlias userAlias)
{
m_alias = userAlias.getName();
// propagate to SelectionCriteria,not to Criteria
for (int i = 0; i < m_criteria.size(); i++)
{
if (!(m_criteria.elementAt(i) instanceof Criteria))
{
((SelectionCriteria) m_criteria.elementAt(i)).setAlias(userAlias);
}
}
} | java |
public Map getPathClasses()
{
if (m_pathClasses.isEmpty())
{
if (m_parentCriteria == null)
{
if (m_query == null)
{
return m_pathClasses;
}
else
{
return m_query.getPathClasses();
}
}
else
{
return m_parentCriteria.getPathClasses();
}
}
else
{
return m_pathClasses;
}
} | java |
public void beforeBatch(PreparedStatement stmt) throws PlatformException
{
// Check for Oracle batching support
final Method methodSetExecuteBatch;
final Method methodSendBatch;
methodSetExecuteBatch = ClassHelper.getMethod(stmt, "setExecuteBatch", PARAM_TYPE_INTEGER);
methodSendBatch = ClassHelper.getMethod(stmt, "sendBatch", null);
final boolean statementBatchingSupported = methodSetExecuteBatch != null && methodSendBatch != null;
if (statementBatchingSupported)
{
try
{
// Set number of statements per batch
methodSetExecuteBatch.invoke(stmt, PARAM_STATEMENT_BATCH_SIZE);
m_batchStatementsInProgress.put(stmt, methodSendBatch);
}
catch (Exception e)
{
throw new PlatformException(e.getLocalizedMessage(), e);
}
}
else
{
super.beforeBatch(stmt);
}
} | java |
public void addBatch(PreparedStatement stmt) throws PlatformException
{
// Check for Oracle batching support
final boolean statementBatchingSupported = m_batchStatementsInProgress.containsKey(stmt);
if (statementBatchingSupported)
{
try
{
stmt.executeUpdate();
}
catch (SQLException e)
{
throw new PlatformException(e.getLocalizedMessage(), e);
}
}
else
{
super.addBatch(stmt);
}
} | java |
public int[] executeBatch(PreparedStatement stmt) throws PlatformException
{
// Check for Oracle batching support
final Method methodSendBatch = (Method) m_batchStatementsInProgress.remove(stmt);
final boolean statementBatchingSupported = methodSendBatch != null;
int[] retval = null;
if (statementBatchingSupported)
{
try
{
// sendBatch() returns total row count as an Integer
methodSendBatch.invoke(stmt, null);
}
catch (Exception e)
{
throw new PlatformException(e.getLocalizedMessage(), e);
}
}
else
{
retval = super.executeBatch(stmt);
}
return retval;
} | java |
public BeanDefinition toInternal(BeanDefinitionInfo beanDefinitionInfo) {
if (beanDefinitionInfo instanceof GenericBeanDefinitionInfo) {
GenericBeanDefinitionInfo genericInfo = (GenericBeanDefinitionInfo) beanDefinitionInfo;
GenericBeanDefinition def = new GenericBeanDefinition();
def.setBeanClassName(genericInfo.getClassName());
if (genericInfo.getPropertyValues() != null) {
MutablePropertyValues propertyValues = new MutablePropertyValues();
for (Entry<String, BeanMetadataElementInfo> entry : genericInfo.getPropertyValues().entrySet()) {
BeanMetadataElementInfo info = entry.getValue();
propertyValues.add(entry.getKey(), toInternal(info));
}
def.setPropertyValues(propertyValues);
}
return def;
} else if (beanDefinitionInfo instanceof ObjectBeanDefinitionInfo) {
ObjectBeanDefinitionInfo objectInfo = (ObjectBeanDefinitionInfo) beanDefinitionInfo;
return createBeanDefinitionByIntrospection(objectInfo.getObject());
} else {
throw new IllegalArgumentException("Conversion to internal of " + beanDefinitionInfo.getClass().getName()
+ " not implemented");
}
} | java |
public BeanDefinitionInfo toDto(BeanDefinition beanDefinition) {
if (beanDefinition instanceof GenericBeanDefinition) {
GenericBeanDefinitionInfo info = new GenericBeanDefinitionInfo();
info.setClassName(beanDefinition.getBeanClassName());
if (beanDefinition.getPropertyValues() != null) {
Map<String, BeanMetadataElementInfo> propertyValues = new HashMap<String, BeanMetadataElementInfo>();
for (PropertyValue value : beanDefinition.getPropertyValues().getPropertyValueList()) {
Object obj = value.getValue();
if (obj instanceof BeanMetadataElement) {
propertyValues.put(value.getName(), toDto((BeanMetadataElement) obj));
} else {
throw new IllegalArgumentException("Type " + obj.getClass().getName()
+ " is not a BeanMetadataElement for property: " + value.getName());
}
}
info.setPropertyValues(propertyValues);
}
return info;
} else {
throw new IllegalArgumentException("Conversion to DTO of " + beanDefinition.getClass().getName()
+ " not implemented");
}
} | java |
private void validate(Object object) {
Set<ConstraintViolation<Object>> viols = validator.validate(object);
for (ConstraintViolation<Object> constraintViolation : viols) {
if (Null.class.isAssignableFrom(constraintViolation.getConstraintDescriptor().getAnnotation().getClass())) {
Object o = constraintViolation.getLeafBean();
Iterator<Node> iterator = constraintViolation.getPropertyPath().iterator();
String propertyName = null;
while (iterator.hasNext()) {
propertyName = iterator.next().getName();
}
if (propertyName != null) {
try {
PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(o.getClass(), propertyName);
descriptor.getWriteMethod().invoke(o, new Object[] { null });
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
} | java |
protected void initializeJdbcConnection(Connection con, JdbcConnectionDescriptor jcd)
throws LookupException
{
try
{
PlatformFactory.getPlatformFor(jcd).initializeJdbcConnection(jcd, con);
}
catch (PlatformException e)
{
throw new LookupException("Platform dependent initialization of connection failed", e);
}
} | java |
protected Connection newConnectionFromDataSource(JdbcConnectionDescriptor jcd)
throws LookupException
{
Connection retval = null;
// use JNDI lookup
DataSource ds = jcd.getDataSource();
if (ds == null)
{
// [tomdz] Would it suffice to store the datasources only at the JCDs ?
// Only possible problem would be serialization of the JCD because
// the data source object in the JCD does not 'survive' this
ds = (DataSource) dataSourceCache.get(jcd.getDatasourceName());
}
try
{
if (ds == null)
{
/**
* this synchronization block won't be a big deal as we only look up
* new datasources not found in the map.
*/
synchronized (dataSourceCache)
{
InitialContext ic = new InitialContext();
ds = (DataSource) ic.lookup(jcd.getDatasourceName());
/**
* cache the datasource lookup.
*/
dataSourceCache.put(jcd.getDatasourceName(), ds);
}
}
if (jcd.getUserName() == null)
{
retval = ds.getConnection();
}
else
{
retval = ds.getConnection(jcd.getUserName(), jcd.getPassWord());
}
}
catch (SQLException sqlEx)
{
log.error("SQLException thrown while trying to get Connection from Datasource (" +
jcd.getDatasourceName() + ")", sqlEx);
throw new LookupException("SQLException thrown while trying to get Connection from Datasource (" +
jcd.getDatasourceName() + ")", sqlEx);
}
catch (NamingException namingEx)
{
log.error("Naming Exception while looking up DataSource (" + jcd.getDatasourceName() + ")", namingEx);
throw new LookupException("Naming Exception while looking up DataSource (" + jcd.getDatasourceName() +
")", namingEx);
}
// initialize connection
initializeJdbcConnection(retval, jcd);
if(log.isDebugEnabled()) log.debug("Create new connection using DataSource: "+retval);
return retval;
} | java |
protected Connection newConnectionFromDriverManager(JdbcConnectionDescriptor jcd)
throws LookupException
{
Connection retval = null;
// use JDBC DriverManager
final String driver = jcd.getDriver();
final String url = getDbURL(jcd);
try
{
// loads the driver - NB call to newInstance() added to force initialisation
ClassHelper.getClass(driver, true);
final String user = jcd.getUserName();
final String password = jcd.getPassWord();
final Properties properties = getJdbcProperties(jcd, user, password);
if (properties.isEmpty())
{
if (user == null)
{
retval = DriverManager.getConnection(url);
}
else
{
retval = DriverManager.getConnection(url, user, password);
}
}
else
{
retval = DriverManager.getConnection(url, properties);
}
}
catch (SQLException sqlEx)
{
log.error("Error getting Connection from DriverManager with url (" + url + ") and driver (" + driver + ")", sqlEx);
throw new LookupException("Error getting Connection from DriverManager with url (" + url + ") and driver (" + driver + ")", sqlEx);
}
catch (ClassNotFoundException cnfEx)
{
log.error(cnfEx);
throw new LookupException("A class was not found", cnfEx);
}
catch (Exception e)
{
log.error("Instantiation of jdbc driver failed", e);
throw new LookupException("Instantiation of jdbc driver failed", e);
}
// initialize connection
initializeJdbcConnection(retval, jcd);
if(log.isDebugEnabled()) log.debug("Create new connection using DriverManager: "+retval);
return retval;
} | java |
private void prepareModel(DescriptorRepository model)
{
TreeMap result = new TreeMap();
for (Iterator it = model.getDescriptorTable().values().iterator(); it.hasNext();)
{
ClassDescriptor classDesc = (ClassDescriptor)it.next();
if (classDesc.getFullTableName() == null)
{
// not mapped to a database table
continue;
}
String elementName = getElementName(classDesc);
Table mappedTable = getTableFor(elementName);
Map columnsMap = getColumnsFor(elementName);
Map requiredAttributes = getRequiredAttributes(elementName);
List classDescs = getClassDescriptorsMappingTo(elementName);
if (mappedTable == null)
{
mappedTable = _schema.findTable(classDesc.getFullTableName());
if (mappedTable == null)
{
continue;
}
columnsMap = new TreeMap();
requiredAttributes = new HashMap();
classDescs = new ArrayList();
_elementToTable.put(elementName, mappedTable);
_elementToClassDescriptors.put(elementName, classDescs);
_elementToColumnMap.put(elementName, columnsMap);
_elementToRequiredAttributesMap.put(elementName, requiredAttributes);
}
classDescs.add(classDesc);
extractAttributes(classDesc, mappedTable, columnsMap, requiredAttributes);
}
extractIndirectionTables(model, _schema);
} | java |
@Override
protected final void subAppend(final LoggingEvent event) {
if (event instanceof ScheduledFileRollEvent) {
// the scheduled append() call has been made by a different thread
synchronized (this) {
if (this.closed) {
// just consume the event
return;
}
this.rollFile(event);
}
} else if (event instanceof FileRollEvent) {
// definitely want to avoid rolling here whilst a file roll event is still being handled
super.subAppend(event);
} else {
if(event instanceof FoundationLof4jLoggingEvent){
FoundationLof4jLoggingEvent foundationLof4jLoggingEvent = (FoundationLof4jLoggingEvent)event;
foundationLof4jLoggingEvent.setAppenderName(this.getName());
}
this.rollFile(event);
super.subAppend(event);
}
} | java |
public void updateIntegerBelief(String name, int value) {
introspector.storeBeliefValue(this, name, getIntegerBelief(name) + value);
} | java |
public int getIntegerBelief(String name){
Object belief = introspector.getBeliefBase(this).get(name);
int count = 0;
if (belief!=null) {
count = (Integer) belief;
}
return (Integer) count;
} | java |
@Programmatic
public <T> List<T> fromExcel(
final Blob excelBlob,
final Class<T> cls,
final String sheetName) throws ExcelService.Exception {
return fromExcel(excelBlob, new WorksheetSpec(cls, sheetName));
} | java |
public TransactionImpl getCurrentTransaction()
{
TransactionImpl tx = tx_table.get(Thread.currentThread());
if(tx == null)
{
throw new TransactionNotInProgressException("Calling method needed transaction, but no transaction found for current thread :-(");
}
return tx;
} | java |
public String getDefaultTableName()
{
String name = getName();
int lastDotPos = name.lastIndexOf('.');
int lastDollarPos = name.lastIndexOf('$');
return lastDollarPos > lastDotPos ? name.substring(lastDollarPos + 1) : name.substring(lastDotPos + 1);
} | java |
private void sortFields()
{
HashMap fields = new HashMap();
ArrayList fieldsWithId = new ArrayList();
ArrayList fieldsWithoutId = new ArrayList();
FieldDescriptorDef fieldDef;
for (Iterator it = getFields(); it.hasNext(); )
{
fieldDef = (FieldDescriptorDef)it.next();
fields.put(fieldDef.getName(), fieldDef);
if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_ID))
{
fieldsWithId.add(fieldDef.getName());
}
else
{
fieldsWithoutId.add(fieldDef.getName());
}
}
Collections.sort(fieldsWithId, new FieldWithIdComparator(fields));
ArrayList result = new ArrayList();
for (Iterator it = fieldsWithId.iterator(); it.hasNext();)
{
result.add(getField((String)it.next()));
}
for (Iterator it = fieldsWithoutId.iterator(); it.hasNext();)
{
result.add(getField((String)it.next()));
}
_fields = result;
} | java |
public void checkConstraints(String checkLevel) throws ConstraintException
{
// now checking constraints
FieldDescriptorConstraints fieldConstraints = new FieldDescriptorConstraints();
ReferenceDescriptorConstraints refConstraints = new ReferenceDescriptorConstraints();
CollectionDescriptorConstraints collConstraints = new CollectionDescriptorConstraints();
for (Iterator it = getFields(); it.hasNext();)
{
fieldConstraints.check((FieldDescriptorDef)it.next(), checkLevel);
}
for (Iterator it = getReferences(); it.hasNext();)
{
refConstraints.check((ReferenceDescriptorDef)it.next(), checkLevel);
}
for (Iterator it = getCollections(); it.hasNext();)
{
collConstraints.check((CollectionDescriptorDef)it.next(), checkLevel);
}
new ClassDescriptorConstraints().check(this, checkLevel);
} | java |
private boolean contains(ArrayList defs, DefBase obj)
{
for (Iterator it = defs.iterator(); it.hasNext();)
{
if (obj.getName().equals(((DefBase)it.next()).getName()))
{
return true;
}
}
return false;
} | java |
private FieldDescriptorDef cloneField(FieldDescriptorDef fieldDef, String prefix)
{
FieldDescriptorDef copyFieldDef = new FieldDescriptorDef(fieldDef, prefix);
copyFieldDef.setOwner(this);
// we remove properties that are only relevant to the class the features are declared in
copyFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_IGNORE, null);
Properties mod = getModification(copyFieldDef.getName());
if (mod != null)
{
if (!PropertyHelper.toBoolean(mod.getProperty(PropertyHelper.OJB_PROPERTY_IGNORE), false) &&
hasFeature(copyFieldDef.getName()))
{
LogHelper.warn(true,
ClassDescriptorDef.class,
"process",
"Class "+getName()+" has a feature that has the same name as its included field "+
copyFieldDef.getName()+" from class "+fieldDef.getOwner().getName());
}
copyFieldDef.applyModifications(mod);
}
return copyFieldDef;
} | java |
private ReferenceDescriptorDef cloneReference(ReferenceDescriptorDef refDef, String prefix)
{
ReferenceDescriptorDef copyRefDef = new ReferenceDescriptorDef(refDef, prefix);
copyRefDef.setOwner(this);
// we remove properties that are only relevant to the class the features are declared in
copyRefDef.setProperty(PropertyHelper.OJB_PROPERTY_IGNORE, null);
Properties mod = getModification(copyRefDef.getName());
if (mod != null)
{
if (!PropertyHelper.toBoolean(mod.getProperty(PropertyHelper.OJB_PROPERTY_IGNORE), false) &&
hasFeature(copyRefDef.getName()))
{
LogHelper.warn(true,
ClassDescriptorDef.class,
"process",
"Class "+getName()+" has a feature that has the same name as its included reference "+
copyRefDef.getName()+" from class "+refDef.getOwner().getName());
}
copyRefDef.applyModifications(mod);
}
return copyRefDef;
} | java |
private CollectionDescriptorDef cloneCollection(CollectionDescriptorDef collDef, String prefix)
{
CollectionDescriptorDef copyCollDef = new CollectionDescriptorDef(collDef, prefix);
copyCollDef.setOwner(this);
// we remove properties that are only relevant to the class the features are declared in
copyCollDef.setProperty(PropertyHelper.OJB_PROPERTY_IGNORE, null);
Properties mod = getModification(copyCollDef.getName());
if (mod != null)
{
if (!PropertyHelper.toBoolean(mod.getProperty(PropertyHelper.OJB_PROPERTY_IGNORE), false) &&
hasFeature(copyCollDef.getName()))
{
LogHelper.warn(true,
ClassDescriptorDef.class,
"process",
"Class "+getName()+" has a feature that has the same name as its included collection "+
copyCollDef.getName()+" from class "+collDef.getOwner().getName());
}
copyCollDef.applyModifications(mod);
}
return copyCollDef;
} | java |
public Iterator getAllBaseTypes()
{
ArrayList baseTypes = new ArrayList();
baseTypes.addAll(_directBaseTypes.values());
for (int idx = baseTypes.size() - 1; idx >= 0; idx--)
{
ClassDescriptorDef curClassDef = (ClassDescriptorDef)baseTypes.get(idx);
for (Iterator it = curClassDef.getDirectBaseTypes(); it.hasNext();)
{
ClassDescriptorDef curBaseTypeDef = (ClassDescriptorDef)it.next();
if (!baseTypes.contains(curBaseTypeDef))
{
baseTypes.add(0, curBaseTypeDef);
idx++;
}
}
}
return baseTypes.iterator();
} | java |
public Iterator getAllExtentClasses()
{
ArrayList subTypes = new ArrayList();
subTypes.addAll(_extents);
for (int idx = 0; idx < subTypes.size(); idx++)
{
ClassDescriptorDef curClassDef = (ClassDescriptorDef)subTypes.get(idx);
for (Iterator it = curClassDef.getExtentClasses(); it.hasNext();)
{
ClassDescriptorDef curSubTypeDef = (ClassDescriptorDef)it.next();
if (!subTypes.contains(curSubTypeDef))
{
subTypes.add(curSubTypeDef);
}
}
}
return subTypes.iterator();
} | java |
public FieldDescriptorDef getField(String name)
{
FieldDescriptorDef fieldDef = null;
for (Iterator it = _fields.iterator(); it.hasNext(); )
{
fieldDef = (FieldDescriptorDef)it.next();
if (fieldDef.getName().equals(name))
{
return fieldDef;
}
}
return null;
} | java |
public ArrayList getFields(String fieldNames) throws NoSuchFieldException
{
ArrayList result = new ArrayList();
FieldDescriptorDef fieldDef;
String name;
for (CommaListIterator it = new CommaListIterator(fieldNames); it.hasNext();)
{
name = it.getNext();
fieldDef = getField(name);
if (fieldDef == null)
{
throw new NoSuchFieldException(name);
}
result.add(fieldDef);
}
return result;
} | java |
public ArrayList getPrimaryKeys()
{
ArrayList result = new ArrayList();
FieldDescriptorDef fieldDef;
for (Iterator it = getFields(); it.hasNext();)
{
fieldDef = (FieldDescriptorDef)it.next();
if (fieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY, false))
{
result.add(fieldDef);
}
}
return result;
} | java |
public ReferenceDescriptorDef getReference(String name)
{
ReferenceDescriptorDef refDef;
for (Iterator it = _references.iterator(); it.hasNext(); )
{
refDef = (ReferenceDescriptorDef)it.next();
if (refDef.getName().equals(name))
{
return refDef;
}
}
return null;
} | java |
public CollectionDescriptorDef getCollection(String name)
{
CollectionDescriptorDef collDef = null;
for (Iterator it = _collections.iterator(); it.hasNext(); )
{
collDef = (CollectionDescriptorDef)it.next();
if (collDef.getName().equals(name))
{
return collDef;
}
}
return null;
} | java |
public NestedDef getNested(String name)
{
NestedDef nestedDef = null;
for (Iterator it = _nested.iterator(); it.hasNext(); )
{
nestedDef = (NestedDef)it.next();
if (nestedDef.getName().equals(name))
{
return nestedDef;
}
}
return null;
} | java |
public IndexDescriptorDef getIndexDescriptor(String name)
{
IndexDescriptorDef indexDef = null;
for (Iterator it = _indexDescriptors.iterator(); it.hasNext(); )
{
indexDef = (IndexDescriptorDef)it.next();
if (indexDef.getName().equals(name))
{
return indexDef;
}
}
return null;
} | java |
public void addProcedure(ProcedureDef procDef)
{
procDef.setOwner(this);
_procedures.put(procDef.getName(), procDef);
} | java |
public void addProcedureArgument(ProcedureArgumentDef argDef)
{
argDef.setOwner(this);
_procedureArguments.put(argDef.getName(), argDef);
} | java |
public void processClass(String template, Properties attributes) throws XDocletException
{
if (!_model.hasClass(getCurrentClass().getQualifiedName()))
{
// we only want to output the log message once
LogHelper.debug(true, OjbTagsHandler.class, "processClass", "Type "+getCurrentClass().getQualifiedName());
}
ClassDescriptorDef classDef = ensureClassDef(getCurrentClass());
String attrName;
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
classDef.setProperty(attrName, attributes.getProperty(attrName));
}
_curClassDef = classDef;
generate(template);
_curClassDef = null;
} | java |
public void forAllClassDefinitions(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _model.getClasses(); it.hasNext(); )
{
_curClassDef = (ClassDescriptorDef)it.next();
generate(template);
}
_curClassDef = null;
LogHelper.debug(true, OjbTagsHandler.class, "forAllClassDefinitions", "Processed "+_model.getNumClasses()+" types");
} | java |
public void originalClass(String template, Properties attributes) throws XDocletException
{
pushCurrentClass(_curClassDef.getOriginalClass());
generate(template);
popCurrentClass();
} | java |
public String addExtent(Properties attributes) throws XDocletException
{
String name = attributes.getProperty(ATTRIBUTE_NAME);
if (!_model.hasClass(name))
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.COULD_NOT_FIND_TYPE,
new String[]{name}));
}
_curClassDef.addExtentClass(_model.getClass(name));
return "";
} | java |
public void forAllExtents(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curClassDef.getExtentClasses(); it.hasNext(); )
{
_curExtent = (ClassDescriptorDef)it.next();
generate(template);
}
_curExtent = null;
} | java |
public String processIndexDescriptor(Properties attributes) throws XDocletException
{
String name = attributes.getProperty(ATTRIBUTE_NAME);
IndexDescriptorDef indexDef = _curClassDef.getIndexDescriptor(name);
String attrName;
if (indexDef == null)
{
indexDef = new IndexDescriptorDef(name);
_curClassDef.addIndexDescriptor(indexDef);
}
if ((indexDef.getName() == null) || (indexDef.getName().length() == 0))
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.INDEX_NAME_MISSING,
new String[]{_curClassDef.getName()}));
}
attributes.remove(ATTRIBUTE_NAME);
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
indexDef.setProperty(attrName, attributes.getProperty(attrName));
}
return "";
} | java |
public void forAllIndexDescriptorDefinitions(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curClassDef.getIndexDescriptors(); it.hasNext(); )
{
_curIndexDescriptorDef = (IndexDescriptorDef)it.next();
generate(template);
}
_curIndexDescriptorDef = null;
} | java |
public void forAllIndexDescriptorColumns(String template, Properties attributes) throws XDocletException
{
String fields = _curIndexDescriptorDef.getProperty(PropertyHelper.OJB_PROPERTY_FIELDS);
FieldDescriptorDef fieldDef;
String name;
for (CommaListIterator it = new CommaListIterator(fields); it.hasNext();)
{
name = it.getNext();
fieldDef = _curClassDef.getField(name);
if (fieldDef == null)
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.INDEX_FIELD_MISSING,
new String[]{name, _curIndexDescriptorDef.getName(), _curClassDef.getName()}));
}
_curIndexColumn = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN);
generate(template);
}
_curIndexColumn = null;
} | java |
public String processObjectCache(Properties attributes) throws XDocletException
{
ObjectCacheDef objCacheDef = _curClassDef.setObjectCache(attributes.getProperty(ATTRIBUTE_CLASS));
String attrName;
attributes.remove(ATTRIBUTE_CLASS);
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
objCacheDef.setProperty(attrName, attributes.getProperty(attrName));
}
return "";
} | java |
public void forObjectCache(String template, Properties attributes) throws XDocletException
{
_curObjectCacheDef = _curClassDef.getObjectCache();
if (_curObjectCacheDef != null)
{
generate(template);
_curObjectCacheDef = null;
}
} | java |
public String processProcedure(Properties attributes) throws XDocletException
{
String type = attributes.getProperty(ATTRIBUTE_TYPE);
ProcedureDef procDef = _curClassDef.getProcedure(type);
String attrName;
if (procDef == null)
{
procDef = new ProcedureDef(type);
_curClassDef.addProcedure(procDef);
}
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
procDef.setProperty(attrName, attributes.getProperty(attrName));
}
return "";
} | java |
public void forAllProcedures(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curClassDef.getProcedures(); it.hasNext(); )
{
_curProcedureDef = (ProcedureDef)it.next();
generate(template);
}
_curProcedureDef = null;
} | java |
public String processProcedureArgument(Properties attributes) throws XDocletException
{
String id = attributes.getProperty(ATTRIBUTE_NAME);
ProcedureArgumentDef argDef = _curClassDef.getProcedureArgument(id);
String attrName;
if (argDef == null)
{
argDef = new ProcedureArgumentDef(id);
_curClassDef.addProcedureArgument(argDef);
}
attributes.remove(ATTRIBUTE_NAME);
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
argDef.setProperty(attrName, attributes.getProperty(attrName));
}
return "";
} | java |
public void forAllProcedureArguments(String template, Properties attributes) throws XDocletException
{
String argNameList = _curProcedureDef.getProperty(PropertyHelper.OJB_PROPERTY_ARGUMENTS);
for (CommaListIterator it = new CommaListIterator(argNameList); it.hasNext();)
{
_curProcedureArgumentDef = _curClassDef.getProcedureArgument(it.getNext());
generate(template);
}
_curProcedureArgumentDef = null;
} | java |
public void processAnonymousField(Properties attributes) throws XDocletException
{
if (!attributes.containsKey(ATTRIBUTE_NAME))
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.PARAMETER_IS_REQUIRED,
new String[]{ATTRIBUTE_NAME}));
}
String name = attributes.getProperty(ATTRIBUTE_NAME);
FieldDescriptorDef fieldDef = _curClassDef.getField(name);
String attrName;
if (fieldDef == null)
{
fieldDef = new FieldDescriptorDef(name);
_curClassDef.addField(fieldDef);
}
fieldDef.setAnonymous();
LogHelper.debug(false, OjbTagsHandler.class, "processAnonymousField", " Processing anonymous field "+fieldDef.getName());
attributes.remove(ATTRIBUTE_NAME);
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
fieldDef.setProperty(attrName, attributes.getProperty(attrName));
}
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_ACCESS, "anonymous");
} | java |
public void processField(String template, Properties attributes) throws XDocletException
{
String name = OjbMemberTagsHandler.getMemberName();
String defaultType = getDefaultJdbcTypeForCurrentMember();
String defaultConversion = getDefaultJdbcConversionForCurrentMember();
FieldDescriptorDef fieldDef = _curClassDef.getField(name);
String attrName;
if (fieldDef == null)
{
fieldDef = new FieldDescriptorDef(name);
_curClassDef.addField(fieldDef);
}
LogHelper.debug(false, OjbTagsHandler.class, "processField", " Processing field "+fieldDef.getName());
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
fieldDef.setProperty(attrName, attributes.getProperty(attrName));
}
// storing additional info for later use
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_JAVA_TYPE,
OjbMemberTagsHandler.getMemberType().getQualifiedName());
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_JDBC_TYPE, defaultType);
if (defaultConversion != null)
{
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION, defaultConversion);
}
_curFieldDef = fieldDef;
generate(template);
_curFieldDef = null;
} | java |
public void processAnonymousReference(Properties attributes) throws XDocletException
{
ReferenceDescriptorDef refDef = _curClassDef.getReference("super");
String attrName;
if (refDef == null)
{
refDef = new ReferenceDescriptorDef("super");
_curClassDef.addReference(refDef);
}
refDef.setAnonymous();
LogHelper.debug(false, OjbTagsHandler.class, "processAnonymousReference", " Processing anonymous reference");
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
refDef.setProperty(attrName, attributes.getProperty(attrName));
}
} | java |
public void processReference(String template, Properties attributes) throws XDocletException
{
String name = OjbMemberTagsHandler.getMemberName();
XClass type = OjbMemberTagsHandler.getMemberType();
int dim = OjbMemberTagsHandler.getMemberDimension();
ReferenceDescriptorDef refDef = _curClassDef.getReference(name);
String attrName;
if (refDef == null)
{
refDef = new ReferenceDescriptorDef(name);
_curClassDef.addReference(refDef);
}
LogHelper.debug(false, OjbTagsHandler.class, "processReference", " Processing reference "+refDef.getName());
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
refDef.setProperty(attrName, attributes.getProperty(attrName));
}
// storing default info for later use
if (type == null)
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER,
new String[]{name}));
}
if (dim > 0)
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.MEMBER_CANNOT_BE_A_REFERENCE,
new String[]{name, _curClassDef.getName()}));
}
refDef.setProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE, type.getQualifiedName());
// searching for default type
String typeName = searchForPersistentSubType(type);
if (typeName != null)
{
refDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CLASS_REF, typeName);
}
_curReferenceDef = refDef;
generate(template);
_curReferenceDef = null;
} | java |
public void forAllReferenceDefinitions(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curClassDef.getReferences(); it.hasNext(); )
{
_curReferenceDef = (ReferenceDescriptorDef)it.next();
// first we check whether it is an inherited anonymous reference
if (_curReferenceDef.isAnonymous() && (_curReferenceDef.getOwner() != _curClassDef))
{
continue;
}
if (!isFeatureIgnored(LEVEL_REFERENCE) &&
!_curReferenceDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
generate(template);
}
}
_curReferenceDef = null;
} | java |
public void processCollection(String template, Properties attributes) throws XDocletException
{
String name = OjbMemberTagsHandler.getMemberName();
CollectionDescriptorDef collDef = _curClassDef.getCollection(name);
String attrName;
if (collDef == null)
{
collDef = new CollectionDescriptorDef(name);
_curClassDef.addCollection(collDef);
}
LogHelper.debug(false, OjbTagsHandler.class, "processCollection", " Processing collection "+collDef.getName());
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
collDef.setProperty(attrName, attributes.getProperty(attrName));
}
if (OjbMemberTagsHandler.getMemberDimension() > 0)
{
// we store the array-element type for later use
collDef.setProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF,
OjbMemberTagsHandler.getMemberType().getQualifiedName());
}
else
{
collDef.setProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE,
OjbMemberTagsHandler.getMemberType().getQualifiedName());
}
_curCollectionDef = collDef;
generate(template);
_curCollectionDef = null;
} | java |
public void forAllCollectionDefinitions(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curClassDef.getCollections(); it.hasNext(); )
{
_curCollectionDef = (CollectionDescriptorDef)it.next();
if (!isFeatureIgnored(LEVEL_COLLECTION) &&
!_curCollectionDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
generate(template);
}
}
_curCollectionDef = null;
} | java |
public String processNested(Properties attributes) throws XDocletException
{
String name = OjbMemberTagsHandler.getMemberName();
XClass type = OjbMemberTagsHandler.getMemberType();
int dim = OjbMemberTagsHandler.getMemberDimension();
NestedDef nestedDef = _curClassDef.getNested(name);
if (type == null)
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER,
new String[]{name}));
}
if (dim > 0)
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.MEMBER_CANNOT_BE_NESTED,
new String[]{name, _curClassDef.getName()}));
}
ClassDescriptorDef nestedTypeDef = _model.getClass(type.getQualifiedName());
if (nestedTypeDef == null)
{
throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER,
new String[]{name}));
}
if (nestedDef == null)
{
nestedDef = new NestedDef(name, nestedTypeDef);
_curClassDef.addNested(nestedDef);
}
LogHelper.debug(false, OjbTagsHandler.class, "processNested", " Processing nested object "+nestedDef.getName()+" of type "+nestedTypeDef.getName());
String attrName;
for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
{
attrName = (String)attrNames.nextElement();
nestedDef.setProperty(attrName, attributes.getProperty(attrName));
}
return "";
} | java |
public String createTorqueSchema(Properties attributes) throws XDocletException
{
String dbName = (String)getDocletContext().getConfigParam(CONFIG_PARAM_DATABASENAME);
_torqueModel = new TorqueModelDef(dbName, _model);
return "";
} | java |
public void forAllTables(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _torqueModel.getTables(); it.hasNext(); )
{
_curTableDef = (TableDef)it.next();
generate(template);
}
_curTableDef = null;
} | java |
public void forAllColumns(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curTableDef.getColumns(); it.hasNext(); )
{
_curColumnDef = (ColumnDef)it.next();
generate(template);
}
_curColumnDef = null;
} | java |
public void forAllForeignkeys(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curTableDef.getForeignkeys(); it.hasNext(); )
{
_curForeignkeyDef = (ForeignkeyDef)it.next();
generate(template);
}
_curForeignkeyDef = null;
} | java |
public void forAllForeignkeyColumnPairs(String template, Properties attributes) throws XDocletException
{
for (int idx = 0; idx < _curForeignkeyDef.getNumColumnPairs(); idx++)
{
_curPairLeft = _curForeignkeyDef.getLocalColumn(idx);
_curPairRight = _curForeignkeyDef.getRemoteColumn(idx);
generate(template);
}
_curPairLeft = null;
_curPairRight = null;
} | java |
public void forAllIndices(String template, Properties attributes) throws XDocletException
{
boolean processUnique = TypeConversionUtil.stringToBoolean(attributes.getProperty(ATTRIBUTE_UNIQUE), false);
// first the default index
_curIndexDef = _curTableDef.getIndex(null);
if ((_curIndexDef != null) && (processUnique == _curIndexDef.isUnique()))
{
generate(template);
}
for (Iterator it = _curTableDef.getIndices(); it.hasNext(); )
{
_curIndexDef = (IndexDef)it.next();
if (!_curIndexDef.isDefault() && (processUnique == _curIndexDef.isUnique()))
{
generate(template);
}
}
_curIndexDef = null;
} | java |
public void forAllIndexColumns(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _curIndexDef.getColumns(); it.hasNext(); )
{
_curColumnDef = _curTableDef.getColumn((String)it.next());
generate(template);
}
_curColumnDef = null;
} | java |
public String name(Properties attributes) throws XDocletException
{
return getDefForLevel(attributes.getProperty(ATTRIBUTE_LEVEL)).getName();
} | java |
public void ifHasName(String template, Properties attributes) throws XDocletException
{
String name = getDefForLevel(attributes.getProperty(ATTRIBUTE_LEVEL)).getName();
if ((name != null) && (name.length() > 0))
{
generate(template);
}
} | java |
public void ifHasProperty(String template, Properties attributes) throws XDocletException
{
String value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
if (value != null)
{
generate(template);
}
} | java |
public String propertyValue(Properties attributes) throws XDocletException
{
String value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
if (value == null)
{
value = attributes.getProperty(ATTRIBUTE_DEFAULT);
}
return value;
} | java |
public void ifPropertyValueEquals(String template, Properties attributes) throws XDocletException
{
String value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
String expected = attributes.getProperty(ATTRIBUTE_VALUE);
if (value == null)
{
value = attributes.getProperty(ATTRIBUTE_DEFAULT);
}
if (expected.equals(value))
{
generate(template);
}
} | java |
public void forAllValuePairs(String template, Properties attributes) throws XDocletException
{
String name = attributes.getProperty(ATTRIBUTE_NAME, "attributes");
String defaultValue = attributes.getProperty(ATTRIBUTE_DEFAULT_RIGHT, "");
String attributePairs = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), name);
if ((attributePairs == null) || (attributePairs.length() == 0))
{
return;
}
String token;
int pos;
for (CommaListIterator it = new CommaListIterator(attributePairs); it.hasNext();)
{
token = it.getNext();
pos = token.indexOf('=');
if (pos >= 0)
{
_curPairLeft = token.substring(0, pos);
_curPairRight = (pos < token.length() - 1 ? token.substring(pos + 1) : defaultValue);
}
else
{
_curPairLeft = token;
_curPairRight = defaultValue;
}
if (_curPairLeft.length() > 0)
{
generate(template);
}
}
_curPairLeft = null;
_curPairRight = null;
} | java |
private ClassDescriptorDef ensureClassDef(XClass original)
{
String name = original.getQualifiedName();
ClassDescriptorDef classDef = _model.getClass(name);
if (classDef == null)
{
classDef = new ClassDescriptorDef(original);
_model.addClass(classDef);
}
return classDef;
} | java |
private void addDirectSubTypes(XClass type, ArrayList subTypes)
{
if (type.isInterface())
{
if (type.getExtendingInterfaces() != null)
{
subTypes.addAll(type.getExtendingInterfaces());
}
// we have to traverse the implementing classes as these array contains all classes that
// implement the interface, not only those who have an "implement" declaration
// note that for whatever reason the declared interfaces are not exported via the XClass interface
// so we have to get them via the underlying class which is hopefully a subclass of AbstractClass
if (type.getImplementingClasses() != null)
{
Collection declaredInterfaces = null;
XClass subType;
for (Iterator it = type.getImplementingClasses().iterator(); it.hasNext(); )
{
subType = (XClass)it.next();
if (subType instanceof AbstractClass)
{
declaredInterfaces = ((AbstractClass)subType).getDeclaredInterfaces();
if ((declaredInterfaces != null) && declaredInterfaces.contains(type))
{
subTypes.add(subType);
}
}
else
{
// Otherwise we have to live with the bug
subTypes.add(subType);
}
}
}
}
else
{
subTypes.addAll(type.getDirectSubclasses());
}
} | java |
private String searchForPersistentSubType(XClass type)
{
ArrayList queue = new ArrayList();
XClass subType;
queue.add(type);
while (!queue.isEmpty())
{
subType = (XClass)queue.get(0);
queue.remove(0);
if (_model.hasClass(subType.getQualifiedName()))
{
return subType.getQualifiedName();
}
addDirectSubTypes(subType, queue);
}
return null;
} | java |
private DefBase getDefForLevel(String level)
{
if (LEVEL_CLASS.equals(level))
{
return _curClassDef;
}
else if (LEVEL_FIELD.equals(level))
{
return _curFieldDef;
}
else if (LEVEL_REFERENCE.equals(level))
{
return _curReferenceDef;
}
else if (LEVEL_COLLECTION.equals(level))
{
return _curCollectionDef;
}
else if (LEVEL_OBJECT_CACHE.equals(level))
{
return _curObjectCacheDef;
}
else if (LEVEL_INDEX_DESC.equals(level))
{
return _curIndexDescriptorDef;
}
else if (LEVEL_TABLE.equals(level))
{
return _curTableDef;
}
else if (LEVEL_COLUMN.equals(level))
{
return _curColumnDef;
}
else if (LEVEL_FOREIGNKEY.equals(level))
{
return _curForeignkeyDef;
}
else if (LEVEL_INDEX.equals(level))
{
return _curIndexDef;
}
else if (LEVEL_PROCEDURE.equals(level))
{
return _curProcedureDef;
}
else if (LEVEL_PROCEDURE_ARGUMENT.equals(level))
{
return _curProcedureArgumentDef;
}
else
{
return null;
}
} | java |
private String getPropertyValue(String level, String name)
{
return getDefForLevel(level).getProperty(name);
} | java |
final void compress(final File backupFile,
final AppenderRollingProperties properties) {
if (this.isCompressed(backupFile)) {
LogLog.debug("Backup log file " + backupFile.getName()
+ " is already compressed");
return; // try not to do unnecessary work
}
final long lastModified = backupFile.lastModified();
if (0L == lastModified) {
LogLog.debug("Backup log file " + backupFile.getName()
+ " may have been scavenged");
return; // backup file may have been scavenged
}
final File deflatedFile = this.createDeflatedFile(backupFile);
if (deflatedFile == null) {
LogLog.debug("Backup log file " + backupFile.getName()
+ " may have been scavenged");
return; // an error occurred creating the file
}
if (this.compress(backupFile, deflatedFile, properties)) {
deflatedFile.setLastModified(lastModified);
FileHelper.getInstance().deleteExisting(backupFile);
LogLog.debug("Compressed backup log file to " + deflatedFile.getName());
} else {
FileHelper.getInstance().deleteExisting(deflatedFile); // clean up
LogLog
.debug("Unable to compress backup log file " + backupFile.getName());
}
} | java |
public static PersistenceBroker createPersistenceBroker(String jcdAlias,
String user,
String password) throws PBFactoryException
{
return PersistenceBrokerFactoryFactory.instance().
createPersistenceBroker(jcdAlias, user, password);
} | java |
public void setRegistrationConfig(RegistrationConfig registrationConfig) {
this.registrationConfig = registrationConfig;
if (registrationConfig.getDefaultConfig()!=null) {
for (String key : registrationConfig.getDefaultConfig().keySet()) {
dynamicConfig.put(key, registrationConfig.getDefaultConfig().get(key));
}
}
} | java |
public void characters(char ch[], int start, int length)
{
if (m_CurrentString == null)
m_CurrentString = new String(ch, start, length);
else
m_CurrentString += new String(ch, start, length);
} | java |
public synchronized boolean hasNext()
{
try
{
if (!isHasCalledCheck())
{
setHasCalledCheck(true);
setHasNext(getRsAndStmt().m_rs.next());
if (!getHasNext())
{
autoReleaseDbResources();
}
}
}
catch (Exception ex)
{
setHasNext(false);
autoReleaseDbResources();
if(ex instanceof ResourceClosedException)
{
throw (ResourceClosedException)ex;
}
if(ex instanceof SQLException)
{
throw new PersistenceBrokerSQLException("Calling ResultSet.next() failed", (SQLException) ex);
}
else
{
throw new PersistenceBrokerException("Can't get next row from ResultSet", ex);
}
}
if (logger.isDebugEnabled())
logger.debug("hasNext() -> " + getHasNext());
return getHasNext();
} | java |
public synchronized Object next() throws NoSuchElementException
{
try
{
if (!isHasCalledCheck())
{
hasNext();
}
setHasCalledCheck(false);
if (getHasNext())
{
Object obj = getObjectFromResultSet();
m_current_row++;
// Invoke events on PersistenceBrokerAware instances and listeners
// set target object
if (!disableLifeCycleEvents)
{
getAfterLookupEvent().setTarget(obj);
getBroker().fireBrokerEvent(getAfterLookupEvent());
getAfterLookupEvent().setTarget(null);
}
return obj;
}
else
{
throw new NoSuchElementException("inner hasNext was false");
}
}
catch (ResourceClosedException ex)
{
autoReleaseDbResources();
throw ex;
}
catch (NoSuchElementException ex)
{
autoReleaseDbResources();
logger.error("Error while iterate ResultSet for query " + m_queryObject, ex);
throw new NoSuchElementException("Could not obtain next object: " + ex.getMessage());
}
} | java |
private Collection getOwnerObjects()
{
Collection owners = new Vector();
while (hasNext())
{
owners.add(next());
}
return owners;
} | java |
private void prefetchRelationships(Query query)
{
List prefetchedRel;
Collection owners;
String relName;
RelationshipPrefetcher[] prefetchers;
if (query == null || query.getPrefetchedRelationships() == null || query.getPrefetchedRelationships().isEmpty())
{
return;
}
if (!supportsAdvancedJDBCCursorControl())
{
logger.info("prefetching relationships requires JDBC level 2.0");
return;
}
// prevent releasing of DBResources
setInBatchedMode(true);
prefetchedRel = query.getPrefetchedRelationships();
prefetchers = new RelationshipPrefetcher[prefetchedRel.size()];
// disable auto retrieve for all prefetched relationships
for (int i = 0; i < prefetchedRel.size(); i++)
{
relName = (String) prefetchedRel.get(i);
prefetchers[i] = getBroker().getRelationshipPrefetcherFactory()
.createRelationshipPrefetcher(getQueryObject().getClassDescriptor(), relName);
prefetchers[i].prepareRelationshipSettings();
}
// materialize ALL owners of this Iterator
owners = getOwnerObjects();
// prefetch relationships and associate with owners
for (int i = 0; i < prefetchedRel.size(); i++)
{
prefetchers[i].prefetchRelationship(owners);
}
// reset auto retrieve for all prefetched relationships
for (int i = 0; i < prefetchedRel.size(); i++)
{
prefetchers[i].restoreRelationshipSettings();
}
try
{
getRsAndStmt().m_rs.beforeFirst(); // reposition resultset jdbc 2.0
}
catch (SQLException e)
{
logger.error("beforeFirst failed !", e);
}
setInBatchedMode(false);
setHasCalledCheck(false);
} | java |
protected Object getProxyFromResultSet() throws PersistenceBrokerException
{
// 1. get Identity of current row:
Identity oid = getIdentityFromResultSet();
// 2. return a Proxy instance:
return getBroker().createProxy(getItemProxyClass(), oid);
} | java |
protected int countedSize() throws PersistenceBrokerException
{
Query countQuery = getBroker().serviceBrokerHelper().getCountQuery(getQueryObject().getQuery());
ResultSetAndStatement rsStmt;
ClassDescriptor cld = getQueryObject().getClassDescriptor();
int count = 0;
// BRJ: do not use broker.getCount() because it's extent-aware
// the count we need here must not include extents !
if (countQuery instanceof QueryBySQL)
{
String countSql = ((QueryBySQL) countQuery).getSql();
rsStmt = getBroker().serviceJdbcAccess().executeSQL(countSql, cld, Query.NOT_SCROLLABLE);
}
else
{
rsStmt = getBroker().serviceJdbcAccess().executeQuery(countQuery, cld);
}
try
{
if (rsStmt.m_rs.next())
{
count = rsStmt.m_rs.getInt(1);
}
}
catch (SQLException e)
{
throw new PersistenceBrokerException(e);
}
finally
{
rsStmt.close();
}
return count;
} | java |
public boolean absolute(int row) throws PersistenceBrokerException
{
boolean retval;
if (supportsAdvancedJDBCCursorControl())
{
retval = absoluteAdvanced(row);
}
else
{
retval = absoluteBasic(row);
}
return retval;
} | java |
private boolean absoluteBasic(int row)
{
boolean retval = false;
if (row > m_current_row)
{
try
{
while (m_current_row < row && getRsAndStmt().m_rs.next())
{
m_current_row++;
}
if (m_current_row == row)
{
retval = true;
}
else
{
setHasCalledCheck(true);
setHasNext(false);
retval = false;
autoReleaseDbResources();
}
}
catch (Exception ex)
{
setHasCalledCheck(true);
setHasNext(false);
retval = false;
}
}
else
{
logger.info("Your driver does not support advanced JDBC Functionality, " +
"you cannot call absolute() with a position < current");
}
return retval;
} | java |
private boolean absoluteAdvanced(int row)
{
boolean retval = false;
try
{
if (getRsAndStmt().m_rs != null)
{
if (row == 0)
{
getRsAndStmt().m_rs.beforeFirst();
}
else
{
retval = getRsAndStmt().m_rs.absolute(row);
}
m_current_row = row;
setHasCalledCheck(false);
}
}
catch (SQLException e)
{
advancedJDBCSupport = false;
}
return retval;
} | java |
private String safeToString(Object obj)
{
String toString = null;
if (obj != null)
{
try
{
toString = obj.toString();
}
catch (Throwable ex)
{
toString = "BAD toString() impl for " + obj.getClass().getName();
}
}
return toString;
} | java |
public void setRowReader(String newReaderClassName)
{
try
{
m_rowReader =
(RowReader) ClassHelper.newInstance(
newReaderClassName,
ClassDescriptor.class,
this);
}
catch (Exception e)
{
throw new MetadataException("Instantiating of current set RowReader failed", e);
}
} | java |
public void setClassOfObject(Class c)
{
m_Class = c;
isAbstract = Modifier.isAbstract(m_Class.getModifiers());
// TODO : Shouldn't the HashMap in DescriptorRepository be updated as well?
} | java |
public void addFieldDescriptor(FieldDescriptor fld)
{
fld.setClassDescriptor(this); // BRJ
if (m_FieldDescriptions == null)
{
m_FieldDescriptions = new FieldDescriptor[1];
m_FieldDescriptions[0] = fld;
}
else
{
int size = m_FieldDescriptions.length;
FieldDescriptor[] tmpArray = new FieldDescriptor[size + 1];
System.arraycopy(m_FieldDescriptions, 0, tmpArray, 0, size);
tmpArray[size] = fld;
m_FieldDescriptions = tmpArray;
// 2. Sort fields according to their getOrder() Property
Arrays.sort(m_FieldDescriptions, FieldDescriptor.getComparator());
}
m_fieldDescriptorNameMap = null;
m_PkFieldDescriptors = null;
m_nonPkFieldDescriptors = null;
m_lockingFieldDescriptors = null;
m_RwFieldDescriptors = null;
m_RwNonPkFieldDescriptors = null;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.