_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q9500 | Log4jLoggerImpl.isLog4JConfigured | train | private static synchronized boolean isLog4JConfigured()
{
if(!log4jConfigured)
{
Enumeration en = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
{
log4jConfigured = true;
}
else
{
Enumeration cats = LogManager.getCurrentLoggers();
while (cats.hasMoreElements())
{
org.apache.log4j.Logger c = (org.apache.log4j.Logger) cats.nextElement();
if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
{
log4jConfigured = true;
}
}
}
if(log4jConfigured)
{
String msg = "Log4J is already configured, will not search for log4j properties file";
LoggerFactory.getBootLogger().info(msg);
}
else
{
LoggerFactory.getBootLogger().info("Log4J is not configured");
}
}
return log4jConfigured;
} | java | {
"resource": ""
} |
q9501 | Log4jLoggerImpl.getLogger | train | private org.apache.log4j.Logger getLogger()
{
/*
Logger interface extends Serializable, thus Log field is
declared 'transient' and we have to null-check
*/
if (logger == null)
{
logger = org.apache.log4j.Logger.getLogger(name);
}
return logger;
} | java | {
"resource": ""
} |
q9502 | Log4jLoggerImpl.debug | train | public final void debug(Object pObject)
{
getLogger().log(FQCN, Level.DEBUG, pObject, null);
} | java | {
"resource": ""
} |
q9503 | Log4jLoggerImpl.info | train | public final void info(Object pObject)
{
getLogger().log(FQCN, Level.INFO, pObject, null);
} | java | {
"resource": ""
} |
q9504 | Log4jLoggerImpl.warn | train | public final void warn(Object pObject)
{
getLogger().log(FQCN, Level.WARN, pObject, null);
} | java | {
"resource": ""
} |
q9505 | Log4jLoggerImpl.error | train | public final void error(Object pObject)
{
getLogger().log(FQCN, Level.ERROR, pObject, null);
} | java | {
"resource": ""
} |
q9506 | Log4jLoggerImpl.fatal | train | public final void fatal(Object pObject)
{
getLogger().log(FQCN, Level.FATAL, pObject, null);
} | java | {
"resource": ""
} |
q9507 | HibernateLayerUtil.getPropertyClass | train | protected Class<?> getPropertyClass(ClassMetadata meta, String propertyName) throws HibernateLayerException {
// try to assure the correct separator is used
propertyName = propertyName.replace(XPATH_SEPARATOR, SEPARATOR);
if (propertyName.contains(SEPARATOR)) {
String directProperty = propertyName.substring(0, propertyName.indexOf(SEPARATOR));
try {
Type prop = meta.getPropertyType(directProperty);
if (prop.isCollectionType()) {
CollectionType coll = (CollectionType) prop;
prop = coll.getElementType((SessionFactoryImplementor) sessionFactory);
}
ClassMetadata propMeta = sessionFactory.getClassMetadata(prop.getReturnedClass());
return getPropertyClass(propMeta, propertyName.substring(propertyName.indexOf(SEPARATOR) + 1));
} catch (HibernateException e) {
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
meta.getEntityName());
}
} else {
try {
return meta.getPropertyType(propertyName).getReturnedClass();
} catch (HibernateException e) {
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
meta.getEntityName());
}
}
} | java | {
"resource": ""
} |
q9508 | HibernateLayerUtil.setSessionFactory | train | public void setSessionFactory(SessionFactory sessionFactory) throws HibernateLayerException {
try {
this.sessionFactory = sessionFactory;
if (null != layerInfo) {
entityMetadata = sessionFactory.getClassMetadata(layerInfo.getFeatureInfo().getDataSourceName());
}
} catch (Exception e) { // NOSONAR
throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_NO_SESSION_FACTORY);
}
} | java | {
"resource": ""
} |
q9509 | Helper.getJDOClass | train | static JDOClass getJDOClass(Class c)
{
JDOClass rc = null;
try
{
JavaModelFactory javaModelFactory = RuntimeJavaModelFactory.getInstance();
JavaModel javaModel = javaModelFactory.getJavaModel(c.getClassLoader());
JDOModel m = JDOModelFactoryImpl.getInstance().getJDOModel(javaModel);
rc = m.getJDOClass(c.getName());
}
catch (RuntimeException ex)
{
throw new JDOFatalInternalException("Not a JDO class: " + c.getName());
}
return rc;
} | java | {
"resource": ""
} |
q9510 | Helper.getLCState | train | static Object getLCState(StateManagerInternal sm)
{
// unfortunately the LifeCycleState classes are package private.
// so we have to do some dirty reflection hack to access them
try
{
Field myLC = sm.getClass().getDeclaredField("myLC");
myLC.setAccessible(true);
return myLC.get(sm);
}
catch (NoSuchFieldException e)
{
return e;
}
catch (IllegalAccessException e)
{
return e;
}
} | java | {
"resource": ""
} |
q9511 | TmsLayer.postConstruct | train | @PostConstruct
protected void postConstruct() throws GeomajasException {
if (null == baseTmsUrl) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "baseTmsUrl");
}
// Make sure we have a base URL we can work with:
if ((baseTmsUrl.startsWith("http://") || baseTmsUrl.startsWith("https://")) && !baseTmsUrl.endsWith("/")) {
baseTmsUrl += "/";
}
// Make sure there is a correct RasterLayerInfo object:
if (layerInfo == null || layerInfo == UNUSABLE_LAYER_INFO) {
try {
tileMap = configurationService.getCapabilities(this);
version = tileMap.getVersion();
extension = tileMap.getTileFormat().getExtension();
layerInfo = configurationService.asLayerInfo(tileMap);
usable = true;
} catch (TmsLayerException e) {
// a layer needs an info object to keep the DtoConfigurationPostProcessor happy !
layerInfo = UNUSABLE_LAYER_INFO;
usable = false;
log.warn("The layer could not be correctly initialized: " + getId(), e);
}
} else if (extension == null) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "extension");
}
if (layerInfo != null) {
// Finally prepare some often needed values:
state = new TileServiceState(geoService, layerInfo);
// when proxying the real url will be resolved later on, just use a simple one for now
boolean proxying = useCache || useProxy || null != authentication;
if (tileMap != null && !proxying) {
urlBuilder = new TileMapUrlBuilder(tileMap);
} else {
urlBuilder = new SimpleTmsUrlBuilder(extension);
}
}
} | java | {
"resource": ""
} |
q9512 | InMemoryLockMapImpl.getReaders | train | public Collection getReaders(Object obj)
{
checkTimedOutLocks();
Identity oid = new Identity(obj,getBroker());
return getReaders(oid);
} | java | {
"resource": ""
} |
q9513 | InMemoryLockMapImpl.removeTimedOutLocks | train | private void removeTimedOutLocks(long timeout)
{
int count = 0;
long maxAge = System.currentTimeMillis() - timeout;
boolean breakFromLoop = false;
ObjectLocks temp = null;
synchronized (locktable)
{
Iterator it = locktable.values().iterator();
/**
* run this loop while:
* - we have more in the iterator
* - the breakFromLoop flag hasn't been set
* - we haven't removed more than the limit for this cleaning iteration.
*/
while (it.hasNext() && !breakFromLoop && (count <= MAX_LOCKS_TO_CLEAN))
{
temp = (ObjectLocks) it.next();
if (temp.getWriter() != null)
{
if (temp.getWriter().getTimestamp() < maxAge)
{
// writer has timed out, set it to null
temp.setWriter(null);
}
}
if (temp.getYoungestReader() < maxAge)
{
// all readers are older than timeout.
temp.getReaders().clear();
if (temp.getWriter() == null)
{
// all readers and writer are older than timeout,
// remove the objectLock from the iterator (which
// is backed by the map, so it will be removed.
it.remove();
}
}
else
{
// we need to walk each reader.
Iterator readerIt = temp.getReaders().values().iterator();
LockEntry readerLock = null;
while (readerIt.hasNext())
{
readerLock = (LockEntry) readerIt.next();
if (readerLock.getTimestamp() < maxAge)
{
// this read lock is old, remove it.
readerIt.remove();
}
}
}
count++;
}
}
} | java | {
"resource": ""
} |
q9514 | JadexConnector.createAgent | train | public void createAgent(String agent_name, String path) {
IComponentIdentifier agent = cmsService.createComponent(agent_name,
path, null, null).get(new ThreadSuspendable());
createdAgents.put(agent_name, agent);
} | java | {
"resource": ""
} |
q9515 | JadexConnector.getAgentsExternalAccess | train | public IExternalAccess getAgentsExternalAccess(String agent_name) {
return cmsService.getExternalAccess(getAgentID(agent_name)).get(
new ThreadSuspendable());
} | java | {
"resource": ""
} |
q9516 | ProductHandler.create | train | public void create(final DbProduct dbProduct) {
if(repositoryHandler.getProduct(dbProduct.getName()) != null){
throw new WebApplicationException(Response.status(Response.Status.CONFLICT).entity("Product already exist!").build());
}
repositoryHandler.store(dbProduct);
} | java | {
"resource": ""
} |
q9517 | ProductHandler.getProduct | train | public DbProduct getProduct(final String name) {
final DbProduct dbProduct = repositoryHandler.getProduct(name);
if(dbProduct == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Product " + name + " does not exist.").build());
}
return dbProduct;
} | java | {
"resource": ""
} |
q9518 | ProductHandler.deleteProduct | train | public void deleteProduct(final String name) {
final DbProduct dbProduct = getProduct(name);
repositoryHandler.deleteProduct(dbProduct.getName());
} | java | {
"resource": ""
} |
q9519 | ProductHandler.setProductModules | train | public void setProductModules(final String name, final List<String> moduleNames) {
final DbProduct dbProduct = getProduct(name);
dbProduct.setModules(moduleNames);
repositoryHandler.store(dbProduct);
} | java | {
"resource": ""
} |
q9520 | JadeAgentIntrospector.getAgentPlans | train | @Override
public Object[] getAgentPlans(String agent_name, Connector connector) {
// Not supported in JADE
connector.getLogger().warning("Non suported method for Jade Platform. There is no plans in Jade platform.");
throw new java.lang.UnsupportedOperationException("Non suported method for Jade Platform. There is no extra properties.");
} | java | {
"resource": ""
} |
q9521 | CollectionProxyDefaultImpl.loadSize | train | protected synchronized int loadSize() throws PersistenceBrokerException
{
PersistenceBroker broker = getBroker();
try
{
return broker.getCount(getQuery());
}
catch (Exception ex)
{
throw new PersistenceBrokerException(ex);
}
finally
{
releaseBroker(broker);
}
} | java | {
"resource": ""
} |
q9522 | CollectionProxyDefaultImpl.loadData | train | protected Collection loadData() throws PersistenceBrokerException
{
PersistenceBroker broker = getBroker();
try
{
Collection result;
if (_data != null) // could be set by listener
{
result = _data;
}
else if (_size != 0)
{
// TODO: returned ManageableCollection should extend Collection to avoid
// this cast
result = (Collection) broker.getCollectionByQuery(getCollectionClass(), getQuery());
}
else
{
result = (Collection)getCollectionClass().newInstance();
}
return result;
}
catch (Exception ex)
{
throw new PersistenceBrokerException(ex);
}
finally
{
releaseBroker(broker);
}
} | java | {
"resource": ""
} |
q9523 | CollectionProxyDefaultImpl.beforeLoading | train | protected void beforeLoading()
{
if (_listeners != null)
{
CollectionProxyListener listener;
if (_perThreadDescriptorsEnabled) {
loadProfileIfNeeded();
}
for (int idx = _listeners.size() - 1; idx >= 0; idx--)
{
listener = (CollectionProxyListener)_listeners.get(idx);
listener.beforeLoading(this);
}
}
} | java | {
"resource": ""
} |
q9524 | CollectionProxyDefaultImpl.clear | train | public void clear()
{
Class collClass = getCollectionClass();
// ECER: assure we notify all objects being removed,
// necessary for RemovalAwareCollections...
if (IRemovalAwareCollection.class.isAssignableFrom(collClass))
{
getData().clear();
}
else
{
Collection coll;
// BRJ: use an empty collection so isLoaded will return true
// for non RemovalAwareCollections only !!
try
{
coll = (Collection) collClass.newInstance();
}
catch (Exception e)
{
coll = new ArrayList();
}
setData(coll);
}
_size = 0;
} | java | {
"resource": ""
} |
q9525 | CollectionProxyDefaultImpl.releaseBroker | train | protected synchronized void releaseBroker(PersistenceBroker broker)
{
/*
arminw:
only close the broker instance if we get
it from the PBF, do nothing if we obtain it from
PBThreadMapping
*/
if (broker != null && _needsClose)
{
_needsClose = false;
broker.close();
}
} | java | {
"resource": ""
} |
q9526 | CollectionProxyDefaultImpl.getBroker | train | protected synchronized PersistenceBroker getBroker() throws PBFactoryException
{
/*
mkalen:
NB! The loadProfileIfNeeded must be called _before_ acquiring a broker below,
since some methods in PersistenceBrokerImpl will keep a local reference to
the descriptor repository that was active during broker construction/refresh
(not checking the repository beeing used on method invocation).
PersistenceBrokerImpl#getClassDescriptor(Class clazz) is such a method,
that will throw ClassNotPersistenceCapableException on the following scenario:
(All happens in one thread only):
t0: activate per-thread metadata changes
t1: load, register and activate profile A
t2: load object O1 witch collection proxy C to objects {O2} (C stores profile key K(A))
t3: close broker from t2
t4: load, register and activate profile B
t5: reference O1.getO2Collection, causing C loadData() to be invoked
t6: C calls getBroker
broker B is created and descriptorRepository is set to descriptors from profile B
t7: C calls loadProfileIfNeeded, re-activating profile A
t8: C calls B.getCollectionByQuery
t9: B gets callback (via QueryReferenceBroker) to getClassDescriptor
the local descriptorRepository from t6 is used!
=> We will now try to query for {O2} with profile B
(even though we re-activated profile A in t7)
=> ClassNotPersistenceCapableException
Keeping loadProfileIfNeeded() at the start of this method changes everything from t6:
t6: C calls loadProfileIfNeeded, re-activating profile A
t7: C calls getBroker,
broker B is created and descriptorRepository is set to descriptors from profile A
t8: C calls B.getCollectionByQuery
t9: B gets callback to getClassDescriptor,
the local descriptorRepository from t6 is used
=> We query for {O2} with profile A
=> All good :-)
*/
if (_perThreadDescriptorsEnabled)
{
loadProfileIfNeeded();
}
PersistenceBroker broker;
if (getBrokerKey() == null)
{
/*
arminw:
if no PBKey is set we throw an exception, because we don't
know which PB (connection) should be used.
*/
throw new OJBRuntimeException("Can't find associated PBKey. Need PBKey to obtain a valid" +
"PersistenceBroker instance from intern resources.");
}
// first try to use the current threaded broker to avoid blocking
broker = PersistenceBrokerThreadMapping.currentPersistenceBroker(getBrokerKey());
// current broker not found or was closed, create a intern new one
if (broker == null || broker.isClosed())
{
broker = PersistenceBrokerFactory.createPersistenceBroker(getBrokerKey());
// signal that we use a new internal obtained PB instance to read the
// data and that this instance have to be closed after use
_needsClose = true;
}
return broker;
} | java | {
"resource": ""
} |
q9527 | CollectionProxyDefaultImpl.addListener | train | public synchronized void addListener(CollectionProxyListener listener)
{
if (_listeners == null)
{
_listeners = new ArrayList();
}
// to avoid multi-add of same listener, do check
if(!_listeners.contains(listener))
{
_listeners.add(listener);
}
} | java | {
"resource": ""
} |
q9528 | RegistrationConfig.getURN | train | public String getURN() throws InvalidRegistrationContentException {
if (parsedConfig==null || parsedConfig.urn==null || parsedConfig.urn.trim().isEmpty()) {
throw new InvalidRegistrationContentException("Invalid registration config - failed to read mediator URN");
}
return parsedConfig.urn;
} | java | {
"resource": ""
} |
q9529 | FileHelper.deleteExisting | train | public boolean deleteExisting(final File file) {
if (!file.exists()) {
return true;
}
boolean deleted = false;
if (file.canWrite()) {
deleted = file.delete();
} else {
LogLog.debug(file + " is not writeable for delete (retrying)");
}
if (!deleted) {
if (!file.exists()) {
deleted = true;
} else {
file.delete();
deleted = (!file.exists());
}
}
return deleted;
} | java | {
"resource": ""
} |
q9530 | FileHelper.rename | train | public boolean rename(final File from, final File to) {
boolean renamed = false;
if (this.isWriteable(from)) {
renamed = from.renameTo(to);
} else {
LogLog.debug(from + " is not writeable for rename (retrying)");
}
if (!renamed) {
from.renameTo(to);
renamed = (!from.exists());
}
return renamed;
} | java | {
"resource": ""
} |
q9531 | ImplementationImpl.registerOpenDatabase | train | protected synchronized void registerOpenDatabase(DatabaseImpl newDB)
{
DatabaseImpl old_db = getCurrentDatabase();
if (old_db != null)
{
try
{
if (old_db.isOpen())
{
log.warn("## There is still an opened database, close old one ##");
old_db.close();
}
}
catch (Throwable t)
{
//ignore
}
}
if (log.isDebugEnabled()) log.debug("Set current database " + newDB + " PBKey was " + newDB.getPBKey());
setCurrentDatabase(newDB);
// usedDatabases.add(newDB.getPBKey());
} | java | {
"resource": ""
} |
q9532 | DescriptorBase.getAttributeNames | train | public String[] getAttributeNames()
{
Set keys = (attributeMap == null ? new HashSet() : attributeMap.keySet());
String[] result = new String[keys.size()];
keys.toArray(result);
return result;
} | java | {
"resource": ""
} |
q9533 | ModelConstraints.check | train | public void check(ModelDef modelDef, String checkLevel) throws ConstraintException
{
ensureReferencedKeys(modelDef, checkLevel);
checkReferenceForeignkeys(modelDef, checkLevel);
checkCollectionForeignkeys(modelDef, checkLevel);
checkKeyModifications(modelDef, checkLevel);
} | java | {
"resource": ""
} |
q9534 | ModelConstraints.ensureReferencedPKs | train | private void ensureReferencedPKs(ModelDef modelDef, ReferenceDescriptorDef refDef) throws ConstraintException
{
String targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
ClassDescriptorDef targetClassDef = modelDef.getClass(targetClassName);
ensurePKsFromHierarchy(targetClassDef);
} | java | {
"resource": ""
} |
q9535 | ModelConstraints.ensureReferencedPKs | train | private void ensureReferencedPKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
{
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
String indirTable = collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
String localKey = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String remoteKey = collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
boolean hasRemoteKey = remoteKey != null;
ArrayList fittingCollections = new ArrayList();
// we're checking for the fitting remote collection(s) and also
// use their foreignkey as remote-foreignkey in the original collection definition
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
// find the collection in the element class that has the same indirection table
for (Iterator collIt = subTypeDef.getCollections(); collIt.hasNext();)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)collIt.next();
if (indirTable.equals(curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) &&
(collDef != curCollDef) &&
(!hasRemoteKey || CommaListIterator.sameLists(remoteKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY))) &&
(!curCollDef.hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY) ||
CommaListIterator.sameLists(localKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY))))
{
fittingCollections.add(curCollDef);
}
}
}
if (!fittingCollections.isEmpty())
{
// if there is more than one, check that they match, i.e. that they all have the same foreignkeys
if (!hasRemoteKey && (fittingCollections.size() > 1))
{
CollectionDescriptorDef firstCollDef = (CollectionDescriptorDef)fittingCollections.get(0);
String foreignKey = firstCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
for (int idx = 1; idx < fittingCollections.size(); idx++)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
if (!CommaListIterator.sameLists(foreignKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)))
{
throw new ConstraintException("Cannot determine the element-side collection that corresponds to the collection "+
collDef.getName()+" in type "+collDef.getOwner().getName()+
" because there are at least two different collections that would fit."+
" Specifying remote-foreignkey in the original collection "+collDef.getName()+
" will perhaps help");
}
}
// store the found keys at the collections
collDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, foreignKey);
for (int idx = 0; idx < fittingCollections.size(); idx++)
{
CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
curCollDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, localKey);
}
}
}
// copy subclass pk fields into target class (if not already present)
ensurePKsFromHierarchy(elementClassDef);
} | java | {
"resource": ""
} |
q9536 | ModelConstraints.ensureReferencedFKs | train | private void ensureReferencedFKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
{
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = modelDef.getClass(elementClassName);
String fkFieldNames = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
ArrayList missingFields = new ArrayList();
SequencedHashMap fkFields = new SequencedHashMap();
// first we gather all field names
for (CommaListIterator it = new CommaListIterator(fkFieldNames); it.hasNext();)
{
String fieldName = (String)it.next();
FieldDescriptorDef fieldDef = elementClassDef.getField(fieldName);
if (fieldDef == null)
{
missingFields.add(fieldName);
}
fkFields.put(fieldName, fieldDef);
}
// next we traverse all sub types and gather fields as we go
for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext() && !missingFields.isEmpty();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
for (int idx = 0; idx < missingFields.size();)
{
FieldDescriptorDef fieldDef = subTypeDef.getField((String)missingFields.get(idx));
if (fieldDef != null)
{
fkFields.put(fieldDef.getName(), fieldDef);
missingFields.remove(idx);
}
else
{
idx++;
}
}
}
if (!missingFields.isEmpty())
{
throw new ConstraintException("Cannot find field "+missingFields.get(0).toString()+" in the hierarchy with root type "+
elementClassDef.getName()+" which is used as foreignkey in collection "+
collDef.getName()+" in "+collDef.getOwner().getName());
}
// copy the found fields into the element class
ensureFields(elementClassDef, fkFields.values());
} | java | {
"resource": ""
} |
q9537 | ModelConstraints.ensurePKsFromHierarchy | train | private void ensurePKsFromHierarchy(ClassDescriptorDef classDef) throws ConstraintException
{
SequencedHashMap pks = new SequencedHashMap();
for (Iterator it = classDef.getAllExtentClasses(); it.hasNext();)
{
ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
ArrayList subPKs = subTypeDef.getPrimaryKeys();
// check against already present PKs
for (Iterator pkIt = subPKs.iterator(); pkIt.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)pkIt.next();
FieldDescriptorDef foundPKDef = (FieldDescriptorDef)pks.get(fieldDef.getName());
if (foundPKDef != null)
{
if (!isEqual(fieldDef, foundPKDef))
{
throw new ConstraintException("Cannot pull up the declaration of the required primary key "+fieldDef.getName()+
" because its definitions in "+fieldDef.getOwner().getName()+" and "+
foundPKDef.getOwner().getName()+" differ");
}
}
else
{
pks.put(fieldDef.getName(), fieldDef);
}
}
}
ensureFields(classDef, pks.values());
} | java | {
"resource": ""
} |
q9538 | ModelConstraints.ensureFields | train | private void ensureFields(ClassDescriptorDef classDef, Collection fields) throws ConstraintException
{
boolean forceVirtual = !classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true);
for (Iterator it = fields.iterator(); it.hasNext();)
{
FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next();
// First we check whether this field is already present in the class
FieldDescriptorDef foundFieldDef = classDef.getField(fieldDef.getName());
if (foundFieldDef != null)
{
if (isEqual(fieldDef, foundFieldDef))
{
if (forceVirtual)
{
foundFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
}
continue;
}
else
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a different field of the same name");
}
}
// perhaps a reference or collection ?
if (classDef.getCollection(fieldDef.getName()) != null)
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a collection of the same name");
}
if (classDef.getReference(fieldDef.getName()) != null)
{
throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
" from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
" because there is already a reference of the same name");
}
classDef.addFieldClone(fieldDef);
classDef.getField(fieldDef.getName()).setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
}
} | java | {
"resource": ""
} |
q9539 | ModelConstraints.isEqual | train | private boolean isEqual(FieldDescriptorDef first, FieldDescriptorDef second)
{
return first.getName().equals(second.getName()) &&
first.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN)) &&
first.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
} | java | {
"resource": ""
} |
q9540 | ModelConstraints.checkCollectionForeignkeys | train | private void checkCollectionForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
{
collDef = (CollectionDescriptorDef)collIt.next();
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
checkIndirectionTable(modelDef, collDef);
}
else
{
checkCollectionForeignkeys(modelDef, collDef);
}
}
}
}
} | java | {
"resource": ""
} |
q9541 | ModelConstraints.checkReferenceForeignkeys | train | private void checkReferenceForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
checkReferenceForeignkeys(modelDef, refDef);
}
}
}
} | java | {
"resource": ""
} |
q9542 | ModelConstraints.usedByReference | train | private ReferenceDescriptorDef usedByReference(ModelDef modelDef, FieldDescriptorDef fieldDef)
{
String ownerClassName = ((ClassDescriptorDef)fieldDef.getOwner()).getQualifiedName();
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
String targetClassName;
// only relevant for primarykey fields
if (PropertyHelper.toBoolean(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY), false))
{
for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
{
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
{
refDef = (ReferenceDescriptorDef)refIt.next();
targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF).replace('$', '.');
if (ownerClassName.equals(targetClassName))
{
// the field is a primary key of the class referenced by this reference descriptor
return refDef;
}
}
}
}
return null;
} | java | {
"resource": ""
} |
q9543 | ObjectReferenceDescriptor.getForeignKeyValues | train | public Object[] getForeignKeyValues(Object obj, ClassDescriptor mif)
throws PersistenceBrokerException
{
FieldDescriptor[] fks = getForeignKeyFieldDescriptors(mif);
// materialize object only if FK fields are declared
if(fks.length > 0) obj = ProxyHelper.getRealObject(obj);
Object[] result = new Object[fks.length];
for (int i = 0; i < result.length; i++)
{
FieldDescriptor fmd = fks[i];
PersistentField f = fmd.getPersistentField();
// BRJ: do NOT convert.
// conversion is done when binding the sql-statement
//
// FieldConversion fc = fmd.getFieldConversion();
// Object val = fc.javaToSql(f.get(obj));
result[i] = f.get(obj);
}
return result;
} | java | {
"resource": ""
} |
q9544 | ObjectReferenceDescriptor.addForeignKeyField | train | public void addForeignKeyField(int newId)
{
if (m_ForeignKeyFields == null)
{
m_ForeignKeyFields = new Vector();
}
m_ForeignKeyFields.add(new Integer(newId));
} | java | {
"resource": ""
} |
q9545 | ObjectReferenceDescriptor.addForeignKeyField | train | public void addForeignKeyField(String newField)
{
if (m_ForeignKeyFields == null)
{
m_ForeignKeyFields = new Vector();
}
m_ForeignKeyFields.add(newField);
} | java | {
"resource": ""
} |
q9546 | CommonsOJBLockManager.atomicGetOrCreateLock | train | public OJBLock atomicGetOrCreateLock(Object resourceId, Object isolationId)
{
synchronized(globalLocks)
{
MultiLevelLock lock = getLock(resourceId);
if(lock == null)
{
lock = createLock(resourceId, isolationId);
}
return (OJBLock) lock;
}
} | java | {
"resource": ""
} |
q9547 | PdfContext.initSize | train | public void initSize(Rectangle rectangle) {
template = writer.getDirectContent().createTemplate(rectangle.getWidth(), rectangle.getHeight());
} | java | {
"resource": ""
} |
q9548 | PdfContext.getTextSize | train | public Rectangle getTextSize(String text, Font font) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate text width and height
float textWidth = template.getEffectiveStringWidth(text, false);
float ascent = bf.getAscentPoint(text, font.getSize());
float descent = bf.getDescentPoint(text, font.getSize());
float textHeight = ascent - descent;
template.restoreState();
return new Rectangle(0, 0, textWidth, textHeight);
} | java | {
"resource": ""
} |
q9549 | PdfContext.drawText | train | public void drawText(String text, Font font, Rectangle box, Color fontColor) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate descent
float descent = 0;
if (text != null) {
descent = bf.getDescentPoint(text, font.getSize());
}
// calculate the fitting size
Rectangle fit = getTextSize(text, font);
// draw text if necessary
template.setColorFill(fontColor);
template.beginText();
template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f
* (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f
* (box.getHeight() - fit.getHeight()) - descent, 0);
template.endText();
template.restoreState();
} | java | {
"resource": ""
} |
q9550 | PdfContext.strokeRectangle | train | public void strokeRectangle(Rectangle rect, Color color, float linewidth) {
strokeRectangle(rect, color, linewidth, null);
} | java | {
"resource": ""
} |
q9551 | PdfContext.strokeRoundRectangle | train | public void strokeRoundRectangle(Rectangle rect, Color color, float linewidth, float r) {
template.saveState();
setStroke(color, linewidth, null);
template.roundRectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight(), r);
template.stroke();
template.restoreState();
} | java | {
"resource": ""
} |
q9552 | PdfContext.fillRectangle | train | public void fillRectangle(Rectangle rect, Color color) {
template.saveState();
setFill(color);
template.rectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight());
template.fill();
template.restoreState();
} | java | {
"resource": ""
} |
q9553 | PdfContext.strokeEllipse | train | public void strokeEllipse(Rectangle rect, Color color, float linewidth) {
template.saveState();
setStroke(color, linewidth, null);
template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(),
origY + rect.getTop());
template.stroke();
template.restoreState();
} | java | {
"resource": ""
} |
q9554 | PdfContext.fillEllipse | train | public void fillEllipse(Rectangle rect, Color color) {
template.saveState();
setFill(color);
template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(),
origY + rect.getTop());
template.fill();
template.restoreState();
} | java | {
"resource": ""
} |
q9555 | PdfContext.moveRectangleTo | train | public void moveRectangleTo(Rectangle rect, float x, float y) {
float width = rect.getWidth();
float height = rect.getHeight();
rect.setLeft(x);
rect.setBottom(y);
rect.setRight(rect.getLeft() + width);
rect.setTop(rect.getBottom() + height);
} | java | {
"resource": ""
} |
q9556 | PdfContext.translateRectangle | train | public void translateRectangle(Rectangle rect, float dx, float dy) {
float width = rect.getWidth();
float height = rect.getHeight();
rect.setLeft(rect.getLeft() + dx);
rect.setBottom(rect.getBottom() + dy);
rect.setRight(rect.getLeft() + dx + width);
rect.setTop(rect.getBottom() + dy + height);
} | java | {
"resource": ""
} |
q9557 | PdfContext.drawImage | train | public void drawImage(Image img, Rectangle rect, Rectangle clipRect) {
drawImage(img, rect, clipRect, 1);
} | java | {
"resource": ""
} |
q9558 | PdfContext.drawImage | train | 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 | {
"resource": ""
} |
q9559 | PdfContext.drawGeometry | train | 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 | {
"resource": ""
} |
q9560 | PdfContext.toRelative | train | public Rectangle toRelative(Rectangle rect) {
return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop()
- origY);
} | java | {
"resource": ""
} |
q9561 | ODMGBaseBeanImpl.getCount | train | public int getCount(Class target)
{
PersistenceBroker broker = ((HasBroker) odmg.currentTransaction()).getBroker();
int result = broker.getCount(new QueryByCriteria(target));
return result;
} | java | {
"resource": ""
} |
q9562 | VerifyMappingsTask.setClasspath | train | public void setClasspath(Path classpath)
{
if (_classpath == null)
{
_classpath = classpath;
}
else
{
_classpath.append(classpath);
}
log("Verification classpath is "+ _classpath,
Project.MSG_VERBOSE);
} | java | {
"resource": ""
} |
q9563 | VerifyMappingsTask.setClasspathRef | train | public void setClasspathRef(Reference r)
{
createClasspath().setRefid(r);
log("Verification classpath is "+ _classpath,
Project.MSG_VERBOSE);
} | java | {
"resource": ""
} |
q9564 | VerifyMappingsTask.getPersistentFieldClass | train | 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 | {
"resource": ""
} |
q9565 | SymbolizerFilterVisitor.visit | train | @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 | {
"resource": ""
} |
q9566 | SymbolizerFilterVisitor.visit | train | @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 | {
"resource": ""
} |
q9567 | JTATxManager.registerSynchronization | train | 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 | {
"resource": ""
} |
q9568 | JTATxManager.getTransactionManager | train | 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 | {
"resource": ""
} |
q9569 | JTATxManager.abortExternalTx | train | 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 | {
"resource": ""
} |
q9570 | FieldDescriptorConstraints.check | train | 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 | {
"resource": ""
} |
q9571 | FieldDescriptorConstraints.ensureColumn | train | 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 | {
"resource": ""
} |
q9572 | FieldDescriptorConstraints.ensureConversion | train | 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 | {
"resource": ""
} |
q9573 | FieldDescriptorConstraints.ensureLength | train | 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 | {
"resource": ""
} |
q9574 | FieldDescriptorConstraints.ensurePrecisionAndScale | train | 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 | {
"resource": ""
} |
q9575 | FieldDescriptorConstraints.checkLocking | train | 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 | {
"resource": ""
} |
q9576 | FieldDescriptorConstraints.checkSequenceName | train | 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 | {
"resource": ""
} |
q9577 | FieldDescriptorConstraints.checkId | train | 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 | {
"resource": ""
} |
q9578 | FieldDescriptorConstraints.checkReadonlyAccessForNativePKs | train | 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 | {
"resource": ""
} |
q9579 | FieldDescriptorConstraints.checkAnonymous | train | 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 | {
"resource": ""
} |
q9580 | MockAgentPlan.sendRequestToDF | train | 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 | {
"resource": ""
} |
q9581 | CloneableObjectCopyStrategy.copy | train | 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 | {
"resource": ""
} |
q9582 | TableDef.addColumn | train | public void addColumn(ColumnDef columnDef)
{
columnDef.setOwner(this);
_columns.put(columnDef.getName(), columnDef);
} | java | {
"resource": ""
} |
q9583 | TableDef.getIndex | train | 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 | {
"resource": ""
} |
q9584 | TableDef.addForeignkey | train | 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 | {
"resource": ""
} |
q9585 | TableDef.hasForeignkey | train | 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 | {
"resource": ""
} |
q9586 | TableDef.getForeignkey | train | 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 | {
"resource": ""
} |
q9587 | PersistentFieldIntrospectorImpl.findPropertyDescriptor | train | 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 | {
"resource": ""
} |
q9588 | FeatureExpressionServiceImpl.getExpression | train | 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 | {
"resource": ""
} |
q9589 | TimeBasedRollStrategy.findRollStrategy | train | 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 | {
"resource": ""
} |
q9590 | JFrmMain.exitForm | train | 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 | {
"resource": ""
} |
q9591 | PrintComponentInfo.getPrototypeName | train | 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 | {
"resource": ""
} |
q9592 | ExcelServiceImpl.toExcelPivot | train | @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 | {
"resource": ""
} |
q9593 | ConstraintsBase.checkProxyPrefetchingLimit | train | 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 | {
"resource": ""
} |
q9594 | CacheFilter.shouldCache | train | public boolean shouldCache(String requestUri) {
String uri = requestUri.toLowerCase();
return checkContains(uri, cacheIdentifiers) || checkSuffixes(uri, cacheSuffixes);
} | java | {
"resource": ""
} |
q9595 | CacheFilter.shouldNotCache | train | public boolean shouldNotCache(String requestUri) {
String uri = requestUri.toLowerCase();
return checkContains(uri, noCacheIdentifiers) || checkSuffixes(uri, noCacheSuffixes);
} | java | {
"resource": ""
} |
q9596 | CacheFilter.shouldCompress | train | public boolean shouldCompress(String requestUri) {
String uri = requestUri.toLowerCase();
return checkSuffixes(uri, zipSuffixes);
} | java | {
"resource": ""
} |
q9597 | CacheFilter.checkContains | train | public boolean checkContains(String uri, String[] patterns) {
for (String pattern : patterns) {
if (pattern.length() > 0) {
if (uri.contains(pattern)) {
return true;
}
}
}
return false;
} | java | {
"resource": ""
} |
q9598 | CacheFilter.checkSuffixes | train | public boolean checkSuffixes(String uri, String[] patterns) {
for (String pattern : patterns) {
if (pattern.length() > 0) {
if (uri.endsWith(pattern)) {
return true;
}
}
}
return false;
} | java | {
"resource": ""
} |
q9599 | CacheFilter.checkPrefixes | train | public boolean checkPrefixes(String uri, String[] patterns) {
for (String pattern : patterns) {
if (pattern.length() > 0) {
if (uri.startsWith(pattern)) {
return true;
}
}
}
return false;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.