code
stringlengths
73
34.1k
label
stringclasses
1 value
public Collection values() { if (values != null) return values; values = new AbstractCollection() { public int size() { return size; } public void clear() { ReferenceMap.this.clear(); ...
java
public Object toInternal(Attribute<?> attribute) throws GeomajasException { if (attribute instanceof PrimitiveAttribute<?>) { return toPrimitiveObject((PrimitiveAttribute<?>) attribute); } else if (attribute instanceof AssociationAttribute<?>) { return toAssociationObject((AssociationAttribute<?>) attribute);...
java
public Feature toDto(InternalFeature feature, int featureIncludes) throws GeomajasException { if (feature == null) { return null; } Feature dto = new Feature(feature.getId()); if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES) != 0 && null != feature.getAttributes()) { // need to assure...
java
public Class<? extends com.vividsolutions.jts.geom.Geometry> toInternal(LayerType layerType) { switch (layerType) { case GEOMETRY: return com.vividsolutions.jts.geom.Geometry.class; case LINESTRING: return LineString.class; case MULTILINESTRING: return MultiLineString.class; case POINT: re...
java
public LayerType toDto(Class<? extends com.vividsolutions.jts.geom.Geometry> geometryClass) { if (geometryClass == LineString.class) { return LayerType.LINESTRING; } else if (geometryClass == MultiLineString.class) { return LayerType.MULTILINESTRING; } else if (geometryClass == Point.class) { return Laye...
java
public void put(String key, Object object, Envelope envelope) { index.put(key, envelope); cache.put(key, object); }
java
public <TYPE> TYPE get(String key, Class<TYPE> type) { return cache.get(key, type); }
java
public void addFkToThisClass(String column) { if (fksToThisClass == null) { fksToThisClass = new Vector(); } fksToThisClass.add(column); fksToThisClassAry = null; }
java
public void addFkToItemClass(String column) { if (fksToItemClass == null) { fksToItemClass = new Vector(); } fksToItemClass.add(column); fksToItemClassAry = null; }
java
protected String sp_createSequenceQuery(String sequenceName, long maxKey) { return "insert into " + SEQ_TABLE_NAME + " (" + SEQ_NAME_STRING + "," + SEQ_ID_STRING + ") values ('" + sequenceName + "'," + maxKey + ")"; }
java
protected long getUniqueLong(FieldDescriptor field) throws SequenceManagerException { boolean needsCommit = false; long result = 0; /* arminw: use the associated broker instance, check if broker was in tx or we need to commit used connection. */ ...
java
protected long buildNextSequence(PersistenceBroker broker, ClassDescriptor cld, String sequenceName) throws LookupException, SQLException, PlatformException { CallableStatement cs = null; try { Connection con = broker.serviceConnectionManager().getConnection(); ...
java
protected void createSequence(PersistenceBroker broker, FieldDescriptor field, String sequenceName, long maxKey) throws Exception { Statement stmt = null; try { stmt = broker.serviceStatementManager().getGenericStatement(field.getClassDescr...
java
static void init() {// NOPMD determineIfNTEventLogIsSupported(); URL resource = null; final String configurationOptionStr = OptionConverter.getSystemProperty(DEFAULT_CONFIGURATION_KEY, null); if (configurationOptionStr != null) { try { resource = new URL(configurationOptionStr); } catch (Malformed...
java
private static void updateSniffingLoggersLevel(Logger logger) { InputStream settingIS = FoundationLogger.class .getResourceAsStream("/sniffingLogger.xml"); if (settingIS == null) { logger.debug("file sniffingLogger.xml not found in classpath"); } else { try { SAXBuilder builder = new SAXBuilder(); ...
java
public void cache(Identity oid, Object obj) { try { jcsCache.put(oid.toString(), obj); } catch (CacheException e) { throw new RuntimeCacheException(e); } }
java
public void remove(Identity oid) { try { jcsCache.remove(oid.toString()); } catch (CacheException e) { throw new RuntimeCacheException(e.getMessage()); } }
java
public List<GetLocationResult> search(String q, int maxRows, Locale locale) throws Exception { List<GetLocationResult> searchResult = new ArrayList<GetLocationResult>(); String url = URLEncoder.encode(q, "UTF8"); url = "q=select%20*%20from%20geo.placefinder%20where%20text%3D%22" + url + "%22"; if (maxRo...
java
public ClassDescriptor getDescriptorFor(String strClassName) throws ClassNotPersistenceCapableException { ClassDescriptor result = discoverDescriptor(strClassName); if (result == null) { throw new ClassNotPersistenceCapableException(strClassName + " not found in OJB Reposito...
java
protected String getIsolationLevelAsString() { if (defaultIsolationLevel == IL_READ_UNCOMMITTED) { return LITERAL_IL_READ_UNCOMMITTED; } else if (defaultIsolationLevel == IL_READ_COMMITTED) { return LITERAL_IL_READ_COMMITTED; } ...
java
private ClassDescriptor discoverDescriptor(Class clazz) { ClassDescriptor result = (ClassDescriptor) descriptorTable.get(clazz.getName()); if (result == null) { Class superClass = clazz.getSuperclass(); // only recurse if the superClass is not java.lang.Object...
java
private void createResultSubClassesMultipleJoinedTables(List result, ClassDescriptor cld, boolean wholeTree) { List tmp = (List) superClassMultipleJoinedTablesMap.get(cld.getClassOfObject()); if(tmp != null) { result.addAll(tmp); if(wholeTree) { ...
java
public ProxyAuthentication getProxyAuthentication() { // convert authentication to layerAuthentication so we only use one // TODO Remove when removing deprecated authentication field. if (layerAuthentication == null && authentication != null) { layerAuthentication = new LayerAuthentication(); layerAuthentic...
java
@Api public void setUseCache(boolean useCache) { if (null == cacheManagerService && useCache) { log.warn("The caching plugin needs to be available to cache WMS requests. Not setting useCache."); } else { this.useCache = useCache; } }
java
protected boolean check(String id, List<String> includes, List<String> excludes) { return check(id, includes) && !check(id, excludes); }
java
protected boolean check(String id, List<String> includes) { if (null != includes) { for (String check : includes) { if (check(id, check)) { return true; } } } return false; }
java
protected boolean check(String value, String regex) { Pattern pattern = Pattern.compile(regex); return pattern.matcher(value).matches(); }
java
protected ClassDescriptor getClassDescriptor() { ClassDescriptor cld = (ClassDescriptor) m_classDescriptor.get(); if(cld == null) { throw new OJBRuntimeException("Requested ClassDescriptor instance was already GC by JVM"); } return cld; }
java
protected void appendWhereClause(FieldDescriptor[] fields, StringBuffer stmt) throws PersistenceBrokerException { stmt.append(" WHERE "); for(int i = 0; i < fields.length; i++) { FieldDescriptor fmd = fields[i]; stmt.append(fmd.getColumnName()); ...
java
protected void appendWhereClause(ClassDescriptor cld, boolean useLocking, StringBuffer stmt) { FieldDescriptor[] pkFields = cld.getPkFields(); FieldDescriptor[] fields; fields = pkFields; if(useLocking) { FieldDescriptor[] lockingFields = cld.getLockingFi...
java
public Object copy(final Object obj, PersistenceBroker broker) throws ObjectCopyException { ObjectOutputStream oos = null; ObjectInputStream ois = null; try { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); // serialize and pass the object ...
java
public void bindDelete(PreparedStatement stmt, Identity oid, ClassDescriptor cld) throws SQLException { Object[] pkValues = oid.getPrimaryKeyValues(); FieldDescriptor[] pkFields = cld.getPkFields(); int i = 0; try { for (; i < pkValues.length; i++) ...
java
public void bindDelete(PreparedStatement stmt, ClassDescriptor cld, Object obj) throws SQLException { if (cld.getDeleteProcedure() != null) { this.bindProcedure(stmt, cld, obj, cld.getDeleteProcedure()); } else { int index = 1; Val...
java
private int bindStatementValue(PreparedStatement stmt, int index, Object attributeOrQuery, Object value, ClassDescriptor cld) throws SQLException { FieldDescriptor fld = null; // if value is a subQuery bind it if (value instanceof Query) { Query subQuer...
java
public void bindSelect(PreparedStatement stmt, Identity oid, ClassDescriptor cld, boolean callableStmt) throws SQLException { ValueContainer[] values = null; int i = 0; int j = 0; if (cld == null) { cld = m_broker.getClassDescriptor(oid.getObjectsRealClas...
java
public PreparedStatement getDeleteStatement(ClassDescriptor cld) throws PersistenceBrokerSQLException, PersistenceBrokerException { try { return cld.getStatementsForClass(m_conMan).getDeleteStmt(m_conMan.getConnection()); } catch (SQLException e) { ...
java
public PreparedStatement getInsertStatement(ClassDescriptor cds) throws PersistenceBrokerSQLException, PersistenceBrokerException { try { return cds.getStatementsForClass(m_conMan).getInsertStmt(m_conMan.getConnection()); } catch (SQLException e) { ...
java
public PreparedStatement getPreparedStatement(ClassDescriptor cds, String sql, boolean scrollable, int explicitFetchSizeHint, boolean callableStmt) throws PersistenceBrokerException { try { return cds.getStatementsForCla...
java
public PreparedStatement getSelectByPKStatement(ClassDescriptor cds) throws PersistenceBrokerSQLException, PersistenceBrokerException { try { return cds.getStatementsForClass(m_conMan).getSelectByPKStmt(m_conMan.getConnection()); } catch (SQLException e) { ...
java
public PreparedStatement getUpdateStatement(ClassDescriptor cds) throws PersistenceBrokerSQLException, PersistenceBrokerException { try { return cds.getStatementsForClass(m_conMan).getUpdateStmt(m_conMan.getConnection()); } catch (SQLException e) { ...
java
protected ValueContainer[] getAllValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException { return m_broker.serviceBrokerHelper().getAllRwValues(cld, obj); }
java
protected ValueContainer[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Object obj) throws PersistenceBrokerException { return broker.serviceBrokerHelper().getKeyValues(cld, obj); }
java
protected ValueContainer[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Identity oid) throws PersistenceBrokerException { return broker.serviceBrokerHelper().getKeyValues(cld, oid); }
java
protected ValueContainer[] getNonKeyValues(PersistenceBroker broker, ClassDescriptor cld, Object obj) throws PersistenceBrokerException { return broker.serviceBrokerHelper().getNonKeyRwValues(cld, obj); }
java
private void bindProcedure(PreparedStatement stmt, ClassDescriptor cld, Object obj, ProcedureDescriptor proc) throws SQLException { int valueSub = 0; // Figure out if we are using a callable statement. If we are, then we // will need to register one or more output paramet...
java
private void setObjectForStatement(PreparedStatement stmt, int index, Object value, int sqlType) throws SQLException { if (value == null) { m_platform.setNullForStatement(stmt, index, sqlType); } else { m_platform.setObjectForState...
java
public void remove(Identity oid) { if(log.isDebugEnabled()) log.debug("Remove object " + oid); sessionCache.remove(oid); getApplicationCache().remove(oid); }
java
private void putToSessionCache(Identity oid, CacheEntry entry, boolean onlyIfNew) { if(onlyIfNew) { // no synchronization needed, because session cache was used per broker instance if(!sessionCache.containsKey(oid)) sessionCache.put(oid, entry); } else ...
java
private void processQueue() { CacheEntry sv; while((sv = (CacheEntry) queue.poll()) != null) { sessionCache.remove(sv.oid); } }
java
public void beforeClose(PBStateEvent event) { /* arminw: this is a workaround for use in managed environments. When a PB instance is used within a container a PB.close call is done when leave the container method. This close the PB handle (but the real instance is still...
java
public boolean isUpToDate(final DbArtifact artifact) { final List<String> versions = repoHandler.getArtifactVersions(artifact); final String currentVersion = artifact.getVersion(); final String lastDevVersion = getLastVersion(versions); final String lastReleaseVersion = getLastRelease(v...
java
protected Object buildOrRefreshObject(Map row, ClassDescriptor targetClassDescriptor, Object targetObject) { Object result = targetObject; FieldDescriptor fmd; FieldDescriptor[] fields = targetClassDescriptor.getFieldDescriptor(true); if(targetObject == null) { ...
java
protected ClassDescriptor selectClassDescriptor(Map row) throws PersistenceBrokerException { ClassDescriptor result = m_cld; Class ojbConcreteClass = (Class) row.get(OJB_CONCRETE_CLASS_KEY); if(ojbConcreteClass != null) { result = m_cld.getRepository().getDescriptor...
java
protected void load() { properties = new Properties(); String filename = getFilename(); try { URL url = ClassHelper.getResource(filename); if (url == null) { url = (new File(filename)).toURL(); } ...
java
public static void init() { reports.clear(); Reflections reflections = new Reflections(REPORTS_PACKAGE); final Set<Class<? extends Report>> reportClasses = reflections.getSubTypesOf(Report.class); for(Class<? extends Report> c : reportClasses) { LOG.info("Report class: " + c...
java
public InternalTile paint(InternalTile tile) throws RenderException { if (tile.getContentType().equals(VectorTileContentType.URL_CONTENT)) { if (urlBuilder != null) { if (paintGeometries) { urlBuilder.paintGeometries(paintGeometries); urlBuilder.paintLabels(false); tile.setFeatureContent(urlBuil...
java
public void addPropertyChangeListener (String propertyName, java.beans.PropertyChangeListener listener) { this.propertyChangeDelegate.addPropertyChangeListener(propertyName, listener); }
java
public void removePropertyChangeListener (String propertyName, java.beans.PropertyChangeListener listener) { this.propertyChangeDelegate.removePropertyChangeListener(propertyName, listener); }
java
public void setAttribute(String strKey, Object value) { this.propertyChangeDelegate.firePropertyChange(strKey, hmAttributes.put(strKey, value), value); }
java
private void modifyBeliefCount(int count){ introspector.setBeliefValue(getLocalName(), Definitions.RECEIVED_MESSAGE_COUNT, getBeliefCount()+count, null); }
java
private int getBeliefCount() { Integer count = (Integer)introspector.getBeliefBase(ListenerMockAgent.this).get(Definitions.RECEIVED_MESSAGE_COUNT); if (count == null) count = 0; // Just in case, not really sure if this is necessary. return count; }
java
@SuppressWarnings("unchecked") private void addParameters(Model model, HttpServletRequest request) { for (Object objectEntry : request.getParameterMap().entrySet()) { Map.Entry<String, String[]> entry = (Map.Entry<String, String[]>) objectEntry; String key = entry.getKey(); String[] values = entry.getValue(...
java
private Object getParameter(String name, String value) throws ParseException, NumberFormatException { Object result = null; if (name.length() > 0) { switch (name.charAt(0)) { case 'i': if (null == value || value.length() == 0) { value = "0"; } result = new Integer(value); break; ...
java
public SqlStatement getPreparedDeleteStatement(ClassDescriptor cld) { SqlForClass sfc = getSqlForClass(cld); SqlStatement sql = sfc.getDeleteSql(); if(sql == null) { ProcedureDescriptor pd = cld.getDeleteProcedure(); if(pd == null) { ...
java
public SqlStatement getPreparedInsertStatement(ClassDescriptor cld) { SqlStatement sql; SqlForClass sfc = getSqlForClass(cld); sql = sfc.getInsertSql(); if(sql == null) { ProcedureDescriptor pd = cld.getInsertProcedure(); if(pd == null) ...
java
public SelectStatement getPreparedSelectByPkStatement(ClassDescriptor cld) { SelectStatement sql; SqlForClass sfc = getSqlForClass(cld); sql = sfc.getSelectByPKSql(); if(sql == null) { sql = new SqlSelectByPkStatement(m_platform, cld, logger); ...
java
public SelectStatement getPreparedSelectStatement(Query query, ClassDescriptor cld) { SelectStatement sql = new SqlSelectStatement(m_platform, cld, query, logger); if (logger.isDebugEnabled()) { logger.debug("SQL:" + sql.getStatement()); } return sql; ...
java
public SqlStatement getPreparedUpdateStatement(ClassDescriptor cld) { SqlForClass sfc = getSqlForClass(cld); SqlStatement result = sfc.getUpdateSql(); if(result == null) { ProcedureDescriptor pd = cld.getUpdateProcedure(); if(pd == null) ...
java
private String toSQLClause(FieldCriteria c, ClassDescriptor cld) { String colName = toSqlClause(c.getAttribute(), cld); return colName + c.getClause() + c.getValue(); }
java
public SqlStatement getPreparedDeleteStatement(Query query, ClassDescriptor cld) { return new SqlDeleteByQuery(m_platform, cld, query, logger); }
java
private boolean hasBidirectionalAssociation(Class clazz) { ClassDescriptor cdesc; Collection refs; boolean hasBidirAssc; if (_withoutBidirAssc.contains(clazz)) { return false; } if (_withBidirAssc.contains(clazz)) { ...
java
private ArrayList handleDependentReferences(Identity oid, Object userObject, Object[] origFields, Object[] newFields, Object[] newRefs) throws LockingException { ClassDescriptor mif = _pb.getClassDescriptor(userObject.getClass()); FieldDescriptor[] fieldDescs = mif.getFi...
java
private ArrayList handleDependentCollections(Identity oid, Object obj, Object[] origCollections, Object[] newCollections, Object[] newCollectionsOfObjects) throws LockingException { ClassDescriptor mif = _pb.getClassDescriptor(obj.getClass()); Collection col...
java
public void refresh(String[] configLocations) throws GeomajasException { try { setConfigLocations(configLocations); refresh(); } catch (Exception e) { throw new GeomajasException(e, ExceptionCode.REFRESH_CONFIGURATION_FAILED); } }
java
public void rollback() throws GeomajasException { try { setConfigLocations(previousConfigLocations); refresh(); } catch (Exception e) { throw new GeomajasException(e, ExceptionCode.REFRESH_CONFIGURATION_FAILED); } }
java
public String getUrl(){ final StringBuilder sb = new StringBuilder(); sb.append("http://"); sb.append(getHttpConfiguration().getBindHost().get()); sb.append(":"); sb.append(getHttpConfiguration().getPort()); return sb.toString(); }
java
public void addRow(final String... cells){ final Row row = new Row((Object[]) cells); if(!rows.contains(row)){ rows.add(row); } }
java
private static String firstFoundTableName(PersistenceBroker brokerForClass, ClassDescriptor cld) { String name = null; if (!cld.isInterface() && cld.getFullTableName() != null) { return cld.getFullTableName(); } if (cld.isExtent()) { C...
java
public static long getMaxId(PersistenceBroker brokerForClass, Class topLevel, FieldDescriptor original) throws PersistenceBrokerException { long max = 0; long tmp; ClassDescriptor cld = brokerForClass.getClassDescriptor(topLevel); // if class is not an interface / not abstract...
java
public static long getMaxIdForClass( PersistenceBroker brokerForClass, ClassDescriptor cldForOriginalOrExtent, FieldDescriptor original) throws PersistenceBrokerException { FieldDescriptor field = null; if (!original.getClassDescriptor().equals(cldForOriginalOrExtent)) ...
java
public static Identity fromByteArray(final byte[] anArray) throws PersistenceBrokerException { // reverse of the serialize() algorithm: // read from byte[] with a ByteArrayInputStream, decompress with // a GZIPInputStream and then deserialize by reading from the ObjectInputStream ...
java
public byte[] serialize() throws PersistenceBrokerException { // Identity is serialized and written to an ObjectOutputStream // This ObjectOutputstream is compressed by a GZIPOutputStream // and finally written to a ByteArrayOutputStream. // the resulting byte[] is returned ...
java
protected void checkForPrimaryKeys(final Object realObject) throws ClassNotPersistenceCapableException { // if no PKs are specified OJB can't handle this class ! if (m_pkValues == null || m_pkValues.length == 0) { throw createException("OJB needs at least one primary key att...
java
public TileMap getCapabilities(TmsLayer layer) throws TmsLayerException { try { // Create a JaxB unmarshaller: JAXBContext context = JAXBContext.newInstance(TileMap.class); Unmarshaller um = context.createUnmarshaller(); // Find out where to retrieve the capabilities and unmarshall: if (layer.getBaseT...
java
public RasterLayerInfo asLayerInfo(TileMap tileMap) { RasterLayerInfo layerInfo = new RasterLayerInfo(); layerInfo.setCrs(tileMap.getSrs()); layerInfo.setDataSourceName(tileMap.getTitle()); layerInfo.setLayerType(LayerType.RASTER); layerInfo.setMaxExtent(asBbox(tileMap.getBoundingBox())); layerInfo.setTile...
java
private void init_jdbcTypes() throws SQLException { ReportQuery q = (ReportQuery) getQueryObject().getQuery(); m_jdbcTypes = new int[m_attributeCount]; // try to get jdbcTypes from Query if (q.getJdbcTypes() != null) { m_jdbcTypes = q.getJdbcTypes...
java
private int getLiteralId(String literal) throws PersistenceBrokerException { ////logger.debug("lookup: " + literal); try { return tags.getIdByTag(literal); } catch (NullPointerException t) { throw new MetadataException("unknown literal...
java
public final boolean hasReturnValues() { if (this.hasReturnValue()) { return true; } else { // TODO: We may be able to 'pre-calculate' the results // of this loop by just checking arguments as they are added // The onl...
java
protected void addArguments(FieldDescriptor field[]) { for (int i = 0; i < field.length; i++) { ArgumentDescriptor arg = new ArgumentDescriptor(this); arg.setValue(field[i].getAttributeName(), false); this.addArgument(arg); } }
java
@Api public void setNamedRoles(Map<String, List<NamedRoleInfo>> namedRoles) { this.namedRoles = namedRoles; ldapRoleMapping = new HashMap<String, Set<String>>(); for (String roleName : namedRoles.keySet()) { if (!ldapRoleMapping.containsKey(roleName)) { ldapRoleMapping.put(roleName, new HashSet<String>())...
java
public void setPixelPerUnit(double pixelPerUnit) { if (pixelPerUnit < MINIMUM_PIXEL_PER_UNIT) { pixelPerUnit = MINIMUM_PIXEL_PER_UNIT; } if (pixelPerUnit > MAXIMUM_PIXEL_PER_UNIT) { pixelPerUnit = MAXIMUM_PIXEL_PER_UNIT; } this.pixelPerUnit = pixelPerUnit; setPixelPerUnitBased(true); postConstruct()...
java
@PostConstruct protected void postConstruct() { if (pixelPerUnitBased) { // Calculate numerator and denominator if (pixelPerUnit > PIXEL_PER_METER) { this.numerator = pixelPerUnit / conversionFactor; this.denominator = 1; } else { this.numerator = 1; this.denominator = PIXEL_PER_METER / pixe...
java
void nextExecuted(String sql) throws SQLException { count++; if (_order.contains(sql)) { return; } String sqlCmd = sql.substring(0, 7); String rest = sql.substring(sqlCmd.equals("UPDATE ") ? 7 // "UPDATE " : 12); // "INSERT INT...
java
private PreparedStatement prepareBatchStatement(String sql) { String sqlCmd = sql.substring(0, 7); if (sqlCmd.equals("UPDATE ") || sqlCmd.equals("DELETE ") || (_useBatchInserts && sqlCmd.equals("INSERT "))) { PreparedStatement stmt = (PreparedStatement) _statements.get(sql...
java
public static void generateJavaFiles(String requirementsFolder, String platformName, String src_test_dir, String tests_package, String casemanager_package, String loggingPropFile) throws Exception { File reqFolder = new File(requirementsFolder); if (reqFolder.isDirec...
java
public void setPromoted(final boolean promoted) { this.promoted = promoted; for (final Artifact artifact : artifacts) { artifact.setPromoted(promoted); } for (final Module suModule : submodules) { suModule.setPromoted(promoted); } }
java
public void addDependency(final Dependency dependency) { if(dependency != null && !dependencies.contains(dependency)){ this.dependencies.add(dependency); } }
java
public void addSubmodule(final Module submodule) { if (!submodules.contains(submodule)) { submodule.setSubmodule(true); if (promoted) { submodule.setPromoted(promoted); } submodules.add(submodule); } }
java
public void addArtifact(final Artifact artifact) { if (!artifacts.contains(artifact)) { if (promoted) { artifact.setPromoted(promoted); } artifacts.add(artifact); } }
java
public static String get(MessageKey key) { return data.getProperty(key.toString(), key.toString()); }
java