_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q9600 | CacheFilter.configureNoCaching | train | @Api
public static void configureNoCaching(HttpServletResponse response) {
// HTTP 1.0 header:
response.setHeader(HTTP_EXPIRES_HEADER, HTTP_EXPIRES_HEADER_NOCACHE_VALUE);
response.setHeader(HTTP_CACHE_PRAGMA, HTTP_CACHE_PRAGMA_VALUE);
// HTTP 1.1 header:
response.setHeader(HTTP_CACHE_CONTROL_HEADER, HTTP_CACHE_CONTROL_HEADER_NOCACHE_VALUE);
} | java | {
"resource": ""
} |
q9601 | NamingLocator.getContext | train | public static Context getContext()
{
if (ctx == null)
{
try
{
setContext(null);
}
catch (Exception e)
{
log.error("Cannot instantiate the InitialContext", e);
throw new OJBRuntimeException(e);
}
}
return ctx;
} | java | {
"resource": ""
} |
q9602 | NamingLocator.lookup | train | public static Object lookup(String jndiName)
{
if(log.isDebugEnabled()) log.debug("lookup("+jndiName+") was called");
try
{
return getContext().lookup(jndiName);
}
catch (NamingException e)
{
throw new OJBRuntimeException("Lookup failed for: " + jndiName, e);
}
catch(OJBRuntimeException e)
{
throw e;
}
} | java | {
"resource": ""
} |
q9603 | AuthenticationTokenService.getAuthentication | train | public Authentication getAuthentication(String token) {
if (null != token) {
TokenContainer container = tokens.get(token);
if (null != container) {
if (container.isValid()) {
return container.getAuthentication();
} else {
logout(token);
}
}
}
return null;
} | java | {
"resource": ""
} |
q9604 | AuthenticationTokenService.login | train | public String login(Authentication authentication) {
String token = getToken();
return login(token, authentication);
} | java | {
"resource": ""
} |
q9605 | AuthenticationTokenService.login | train | public String login(String token, Authentication authentication) {
if (null == token) {
return login(authentication);
}
tokens.put(token, new TokenContainer(authentication));
return token;
} | java | {
"resource": ""
} |
q9606 | DefBase.getBooleanProperty | train | public boolean getBooleanProperty(String name, boolean defaultValue)
{
return PropertyHelper.toBoolean(_properties.getProperty(name), defaultValue);
} | java | {
"resource": ""
} |
q9607 | FeatureSourceRetriever.getFeatureSource | train | public SimpleFeatureSource getFeatureSource() throws LayerException {
try {
if (dataStore instanceof WFSDataStore) {
return dataStore.getFeatureSource(featureSourceName.replace(":", "_"));
} else {
return dataStore.getFeatureSource(featureSourceName);
}
} catch (IOException e) {
throw new LayerException(e, ExceptionCode.FEATURE_MODEL_PROBLEM,
"Cannot find feature source " + featureSourceName);
} catch (NullPointerException e) {
throw new LayerException(e, ExceptionCode.FEATURE_MODEL_PROBLEM,
"Cannot find feature source " + featureSourceName);
}
} | java | {
"resource": ""
} |
q9608 | FeatureSourceRetriever.setAttributes | train | public void setAttributes(Object feature, Map<String, Attribute> attributes) throws LayerException {
for (Map.Entry<String, Attribute> entry : attributes.entrySet()) {
String name = entry.getKey();
if (!name.equals(getGeometryAttributeName())) {
asFeature(feature).setAttribute(name, entry.getValue());
}
}
} | java | {
"resource": ""
} |
q9609 | HibernateFeatureModel.getAttributeRecursively | train | private Object getAttributeRecursively(Object feature, String name) throws LayerException {
if (feature == null) {
return null;
}
// Split up properties: the first and the rest.
String[] properties = name.split(SEPARATOR_REGEXP, 2);
Object tempFeature;
// If the first property is the identifier:
if (properties[0].equals(getFeatureInfo().getIdentifier().getName())) {
tempFeature = getId(feature);
} else {
Entity entity = entityMapper.asEntity(feature);
HibernateEntity child = (HibernateEntity) entity.getChild(properties[0]);
tempFeature = child == null ? null : child.getObject();
}
// Detect if the first property is a collection (one-to-many):
if (tempFeature instanceof Collection<?>) {
Collection<?> features = (Collection<?>) tempFeature;
Object[] values = new Object[features.size()];
int count = 0;
for (Object value : features) {
if (properties.length == 1) {
values[count++] = value;
} else {
values[count++] = getAttributeRecursively(value, properties[1]);
}
}
return values;
} else { // Else first property is not a collection (one-to-many):
if (properties.length == 1 || tempFeature == null) {
return tempFeature;
} else {
return getAttributeRecursively(tempFeature, properties[1]);
}
}
} | java | {
"resource": ""
} |
q9610 | FiltersHolder.shouldBeInReport | train | public boolean shouldBeInReport(final DbDependency dependency) {
if(dependency == null){
return false;
}
if(dependency.getTarget() == null){
return false;
}
if(corporateFilter != null){
if(!decorator.getShowThirdparty() && !corporateFilter.filter(dependency)){
return false;
}
if(!decorator.getShowCorporate() && corporateFilter.filter(dependency)){
return false;
}
}
if(!scopeHandler.filter(dependency)){
return false;
}
return true;
} | java | {
"resource": ""
} |
q9611 | FiltersHolder.getArtifactFieldsFilters | train | public Map<String, Object> getArtifactFieldsFilters() {
final Map<String, Object> params = new HashMap<String, Object>();
for(final Filter filter: filters){
params.putAll(filter.artifactFilterFields());
}
return params;
} | java | {
"resource": ""
} |
q9612 | FiltersHolder.getModuleFieldsFilters | train | public Map<String, Object> getModuleFieldsFilters() {
final Map<String, Object> params = new HashMap<String, Object>();
for(final Filter filter: filters){
params.putAll(filter.moduleFilterFields());
}
return params;
} | java | {
"resource": ""
} |
q9613 | DBHandlingTask.createDBHandling | train | private DBHandling createDBHandling() throws BuildException
{
if ((_handling == null) || (_handling.length() == 0))
{
throw new BuildException("No handling specified");
}
try
{
String className = "org.apache.ojb.broker.platforms."+
Character.toTitleCase(_handling.charAt(0))+_handling.substring(1)+
"DBHandling";
Class handlingClass = ClassHelper.getClass(className);
return (DBHandling)handlingClass.newInstance();
}
catch (Exception ex)
{
throw new BuildException("Invalid handling '"+_handling+"' specified");
}
} | java | {
"resource": ""
} |
q9614 | DBHandlingTask.addIncludes | train | private void addIncludes(DBHandling handling, FileSet fileSet) throws BuildException
{
DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
StringBuffer includes = new StringBuffer();
for (int idx = 0; idx < files.length; idx++)
{
if (idx > 0)
{
includes.append(",");
}
includes.append(files[idx]);
}
try
{
handling.addDBDefinitionFiles(fileSet.getDir(getProject()).getAbsolutePath(), includes.toString());
}
catch (IOException ex)
{
throw new BuildException(ex);
}
} | java | {
"resource": ""
} |
q9615 | DdlUtilsDataHandling.setModel | train | public void setModel(Database databaseModel, DescriptorRepository objModel)
{
_dbModel = databaseModel;
_preparedModel = new PreparedModel(objModel, databaseModel);
} | java | {
"resource": ""
} |
q9616 | DdlUtilsDataHandling.getDataDTD | train | public void getDataDTD(Writer output) throws DataTaskException
{
try
{
output.write("<!ELEMENT dataset (\n");
for (Iterator it = _preparedModel.getElementNames(); it.hasNext();)
{
String elementName = (String)it.next();
output.write(" ");
output.write(elementName);
output.write("*");
output.write(it.hasNext() ? " |\n" : "\n");
}
output.write(")>\n<!ATTLIST dataset\n name CDATA #REQUIRED\n>\n");
for (Iterator it = _preparedModel.getElementNames(); it.hasNext();)
{
String elementName = (String)it.next();
List classDescs = _preparedModel.getClassDescriptorsMappingTo(elementName);
if (classDescs == null)
{
output.write("\n<!-- Indirection table");
}
else
{
output.write("\n<!-- Mapped to : ");
for (Iterator classDescIt = classDescs.iterator(); classDescIt.hasNext();)
{
ClassDescriptor classDesc = (ClassDescriptor)classDescIt.next();
output.write(classDesc.getClassNameOfObject());
if (classDescIt.hasNext())
{
output.write("\n ");
}
}
}
output.write(" -->\n<!ELEMENT ");
output.write(elementName);
output.write(" EMPTY>\n<!ATTLIST ");
output.write(elementName);
output.write("\n");
for (Iterator attrIt = _preparedModel.getAttributeNames(elementName); attrIt.hasNext();)
{
String attrName = (String)attrIt.next();
output.write(" ");
output.write(attrName);
output.write(" CDATA #");
output.write(_preparedModel.isRequired(elementName, attrName) ? "REQUIRED" : "IMPLIED");
output.write("\n");
}
output.write(">\n");
}
}
catch (IOException ex)
{
throw new DataTaskException(ex);
}
} | java | {
"resource": ""
} |
q9617 | ConstructorHelper.instantiate | train | public static Object instantiate(Class clazz) throws InstantiationException
{
Object result = null;
try
{
result = ClassHelper.newInstance(clazz);
}
catch(IllegalAccessException e)
{
try
{
result = ClassHelper.newInstance(clazz, true);
}
catch(Exception e1)
{
throw new ClassNotPersistenceCapableException("Can't instantiate class '"
+ (clazz != null ? clazz.getName() : "null")
+ "', message was: " + e1.getMessage() + ")", e1);
}
}
return result;
} | java | {
"resource": ""
} |
q9618 | ConstructorHelper.instantiate | train | public static Object instantiate(Constructor constructor) throws InstantiationException
{
if(constructor == null)
{
throw new ClassNotPersistenceCapableException(
"A zero argument constructor was not provided!");
}
Object result = null;
try
{
result = constructor.newInstance(NO_ARGS);
}
catch(InstantiationException e)
{
throw e;
}
catch(Exception e)
{
throw new ClassNotPersistenceCapableException("Can't instantiate class '"
+ (constructor != null ? constructor.getDeclaringClass().getName() : "null")
+ "' with given constructor: " + e.getMessage(), e);
}
return result;
} | java | {
"resource": ""
} |
q9619 | GeoToolsTransactionSynchronization.synchTransaction | train | public void synchTransaction(SimpleFeatureStore featureStore) {
// check if transaction is active, otherwise do nothing (auto-commit mode)
if (TransactionSynchronizationManager.isActualTransactionActive()) {
DataAccess<SimpleFeatureType, SimpleFeature> dataStore = featureStore.getDataStore();
if (!transactions.containsKey(dataStore)) {
Transaction transaction = null;
if (dataStore instanceof JDBCDataStore) {
JDBCDataStore jdbcDataStore = (JDBCDataStore) dataStore;
transaction = jdbcDataStore.buildTransaction(DataSourceUtils
.getConnection(jdbcDataStore.getDataSource()));
} else {
transaction = new DefaultTransaction();
}
transactions.put(dataStore, transaction);
}
featureStore.setTransaction(transactions.get(dataStore));
}
} | java | {
"resource": ""
} |
q9620 | CopyrightCommand.buildCopyrightMap | train | @PostConstruct
protected void buildCopyrightMap() {
if (null == declaredPlugins) {
return;
}
// go over all plug-ins, adding copyright info, avoiding duplicates (on object key)
for (PluginInfo plugin : declaredPlugins.values()) {
for (CopyrightInfo copyright : plugin.getCopyrightInfo()) {
String key = copyright.getKey();
String msg = copyright.getKey() + ": " + copyright.getCopyright() + " : licensed as " +
copyright.getLicenseName() + ", see " + copyright.getLicenseUrl();
if (null != copyright.getSourceUrl()) {
msg += " source " + copyright.getSourceUrl();
}
if (!copyrightMap.containsKey(key)) {
log.info(msg);
copyrightMap.put(key, copyright);
}
}
}
} | java | {
"resource": ""
} |
q9621 | ArtifactHandler.storeIfNew | train | public void storeIfNew(final DbArtifact fromClient) {
final DbArtifact existing = repositoryHandler.getArtifact(fromClient.getGavc());
if(existing != null){
existing.setLicenses(fromClient.getLicenses());
store(existing);
}
if(existing == null){
store(fromClient);
}
} | java | {
"resource": ""
} |
q9622 | ArtifactHandler.addLicense | train | public void addLicense(final String gavc, final String licenseId) {
final DbArtifact dbArtifact = getArtifact(gavc);
// Try to find an existing license that match the new one
final LicenseHandler licenseHandler = new LicenseHandler(repositoryHandler);
final DbLicense license = licenseHandler.resolve(licenseId);
// If there is no existing license that match this one let's use the provided value but
// only if the artifact has no license yet. Otherwise it could mean that users has already
// identify the license manually.
if(license == null){
if(dbArtifact.getLicenses().isEmpty()){
LOG.warn("Add reference to a non existing license called " + licenseId + " in artifact " + dbArtifact.getGavc());
repositoryHandler.addLicenseToArtifact(dbArtifact, licenseId);
}
}
// Add only if the license is not already referenced
else if(!dbArtifact.getLicenses().contains(license.getName())){
repositoryHandler.addLicenseToArtifact(dbArtifact, license.getName());
}
} | java | {
"resource": ""
} |
q9623 | ArtifactHandler.getArtifactVersions | train | public List<String> getArtifactVersions(final String gavc) {
final DbArtifact artifact = getArtifact(gavc);
return repositoryHandler.getArtifactVersions(artifact);
} | java | {
"resource": ""
} |
q9624 | ArtifactHandler.getArtifactLastVersion | train | public String getArtifactLastVersion(final String gavc) {
final List<String> versions = getArtifactVersions(gavc);
final VersionsHandler versionHandler = new VersionsHandler(repositoryHandler);
final String viaCompare = versionHandler.getLastVersion(versions);
if (viaCompare != null) {
return viaCompare;
}
//
// These versions cannot be compared
// Let's use the Collection.max() method by default, so goingo for a fallback
// mechanism.
//
LOG.info("The versions cannot be compared");
return Collections.max(versions);
} | java | {
"resource": ""
} |
q9625 | ArtifactHandler.getArtifact | train | public DbArtifact getArtifact(final String gavc) {
final DbArtifact artifact = repositoryHandler.getArtifact(gavc);
if(artifact == null){
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
.entity("Artifact " + gavc + " does not exist.").build());
}
return artifact;
} | java | {
"resource": ""
} |
q9626 | ArtifactHandler.getOrganization | train | public DbOrganization getOrganization(final DbArtifact dbArtifact) {
final DbModule module = getModule(dbArtifact);
if(module == null || module.getOrganization() == null){
return null;
}
return repositoryHandler.getOrganization(module.getOrganization());
} | java | {
"resource": ""
} |
q9627 | ArtifactHandler.updateDownLoadUrl | train | public void updateDownLoadUrl(final String gavc, final String downLoadUrl) {
final DbArtifact artifact = getArtifact(gavc);
repositoryHandler.updateDownloadUrl(artifact, downLoadUrl);
} | java | {
"resource": ""
} |
q9628 | ArtifactHandler.updateProvider | train | public void updateProvider(final String gavc, final String provider) {
final DbArtifact artifact = getArtifact(gavc);
repositoryHandler.updateProvider(artifact, provider);
} | java | {
"resource": ""
} |
q9629 | ArtifactHandler.getAncestors | train | public List<DbModule> getAncestors(final String gavc, final FiltersHolder filters) {
final DbArtifact dbArtifact = getArtifact(gavc);
return repositoryHandler.getAncestors(dbArtifact, filters);
} | java | {
"resource": ""
} |
q9630 | ArtifactHandler.getArtifactLicenses | train | public List<DbLicense> getArtifactLicenses(final String gavc, final FiltersHolder filters) {
final DbArtifact artifact = getArtifact(gavc);
final List<DbLicense> licenses = new ArrayList<>();
for(final String name: artifact.getLicenses()){
final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(name);
// Here is a license to identify
if(matchingLicenses.isEmpty()){
final DbLicense notIdentifiedLicense = new DbLicense();
notIdentifiedLicense.setName(name);
licenses.add(notIdentifiedLicense);
} else {
matchingLicenses.stream()
.filter(filters::shouldBeInReport)
.forEach(licenses::add);
}
}
return licenses;
} | java | {
"resource": ""
} |
q9631 | ArtifactHandler.removeLicenseFromArtifact | train | public void removeLicenseFromArtifact(final String gavc, final String licenseId) {
final DbArtifact dbArtifact = getArtifact(gavc);
//
// The artifact may not have the exact string associated with it, but rather one
// matching license regexp expression.
//
repositoryHandler.removeLicenseFromArtifact(dbArtifact, licenseId, licenseMatcher);
} | java | {
"resource": ""
} |
q9632 | ArtifactHandler.getModuleJenkinsJobInfo | train | public String getModuleJenkinsJobInfo(final DbArtifact dbArtifact) {
final DbModule module = getModule(dbArtifact);
if(module == null){
return "";
}
final String jenkinsJobUrl = module.getBuildInfo().get("jenkins-job-url");
if(jenkinsJobUrl == null){
return "";
}
return jenkinsJobUrl;
} | java | {
"resource": ""
} |
q9633 | JdbcTypeHelper.getDefaultJdbcTypeFor | train | public static String getDefaultJdbcTypeFor(String javaType)
{
return _jdbcMappings.containsKey(javaType) ? (String)_jdbcMappings.get(javaType) : JDBC_DEFAULT_TYPE;
} | java | {
"resource": ""
} |
q9634 | JdbcTypeHelper.getDefaultConversionFor | train | public static String getDefaultConversionFor(String javaType)
{
return _jdbcConversions.containsKey(javaType) ? (String)_jdbcConversions.get(javaType) : null;
} | java | {
"resource": ""
} |
q9635 | MtoNCollectionPrefetcher.buildMtoNImplementorQuery | train | protected Query buildMtoNImplementorQuery(Collection ids)
{
String[] indFkCols = getFksToThisClass();
String[] indItemFkCols = getFksToItemClass();
FieldDescriptor[] pkFields = getOwnerClassDescriptor().getPkFields();
FieldDescriptor[] itemPkFields = getItemClassDescriptor().getPkFields();
String[] cols = new String[indFkCols.length + indItemFkCols.length];
int[] jdbcTypes = new int[indFkCols.length + indItemFkCols.length];
// concatenate the columns[]
System.arraycopy(indFkCols, 0, cols, 0, indFkCols.length);
System.arraycopy(indItemFkCols, 0, cols, indFkCols.length, indItemFkCols.length);
Criteria crit = buildPrefetchCriteria(ids, indFkCols, indItemFkCols, itemPkFields);
// determine the jdbcTypes of the pks
for (int i = 0; i < pkFields.length; i++)
{
jdbcTypes[i] = pkFields[i].getJdbcType().getType();
}
for (int i = 0; i < itemPkFields.length; i++)
{
jdbcTypes[pkFields.length + i] = itemPkFields[i].getJdbcType().getType();
}
ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria(getItemClassDescriptor().getClassOfObject(), cols,
crit, false);
q.setIndirectionTable(getCollectionDescriptor().getIndirectionTable());
q.setJdbcTypes(jdbcTypes);
CollectionDescriptor cds = getCollectionDescriptor();
//check if collection must be ordered
if (!cds.getOrderBy().isEmpty())
{
Iterator iter = cds.getOrderBy().iterator();
while (iter.hasNext())
{
q.addOrderBy((FieldHelper) iter.next());
}
}
return q;
} | java | {
"resource": ""
} |
q9636 | MtoNCollectionPrefetcher.getFksToThisClass | train | private String[] getFksToThisClass()
{
String indTable = getCollectionDescriptor().getIndirectionTable();
String[] fks = getCollectionDescriptor().getFksToThisClass();
String[] result = new String[fks.length];
for (int i = 0; i < result.length; i++)
{
result[i] = indTable + "." + fks[i];
}
return result;
} | java | {
"resource": ""
} |
q9637 | MtoNCollectionPrefetcher.getPkFieldConversion | train | private FieldConversion[] getPkFieldConversion(ClassDescriptor cld)
{
FieldDescriptor[] pks = cld.getPkFields();
FieldConversion[] fc = new FieldConversion[pks.length];
for (int i= 0; i < pks.length; i++)
{
fc[i] = pks[i].getFieldConversion();
}
return fc;
} | java | {
"resource": ""
} |
q9638 | MtoNCollectionPrefetcher.convert | train | private Object[] convert(FieldConversion[] fcs, Object[] values)
{
Object[] convertedValues = new Object[values.length];
for (int i= 0; i < values.length; i++)
{
convertedValues[i] = fcs[i].sqlToJava(values[i]);
}
return convertedValues;
} | java | {
"resource": ""
} |
q9639 | Application.displayUseCases | train | public void displayUseCases()
{
System.out.println();
for (int i = 0; i < useCases.size(); i++)
{
System.out.println("[" + i + "] " + ((UseCase) useCases.get(i)).getDescription());
}
} | java | {
"resource": ""
} |
q9640 | Application.run | train | public void run()
{
System.out.println(AsciiSplash.getSplashArt());
System.out.println("Welcome to the OJB PB tutorial application");
System.out.println();
// never stop (there is a special use case to quit the application)
while (true)
{
try
{
// select a use case and perform it
UseCase uc = selectUseCase();
uc.apply();
}
catch (Throwable t)
{
broker.close();
System.out.println(t.getMessage());
}
}
} | java | {
"resource": ""
} |
q9641 | Application.selectUseCase | train | public UseCase selectUseCase()
{
displayUseCases();
System.out.println("type in number to select a use case");
String in = readLine();
int index = Integer.parseInt(in);
return (UseCase) useCases.get(index);
} | java | {
"resource": ""
} |
q9642 | DBUtility.getJdbcType | train | public int getJdbcType(String ojbType) throws SQLException
{
int result;
if(ojbType == null) ojbType = "";
ojbType = ojbType.toLowerCase();
if (ojbType.equals("bit"))
result = Types.BIT;
else if (ojbType.equals("tinyint"))
result = Types.TINYINT;
else if (ojbType.equals("smallint"))
result = Types.SMALLINT;
else if (ojbType.equals("integer"))
result = Types.INTEGER;
else if (ojbType.equals("bigint"))
result = Types.BIGINT;
else if (ojbType.equals("float"))
result = Types.FLOAT;
else if (ojbType.equals("real"))
result = Types.REAL;
else if (ojbType.equals("double"))
result = Types.DOUBLE;
else if (ojbType.equals("numeric"))
result = Types.NUMERIC;
else if (ojbType.equals("decimal"))
result = Types.DECIMAL;
else if (ojbType.equals("char"))
result = Types.CHAR;
else if (ojbType.equals("varchar"))
result = Types.VARCHAR;
else if (ojbType.equals("longvarchar"))
result = Types.LONGVARCHAR;
else if (ojbType.equals("date"))
result = Types.DATE;
else if (ojbType.equals("time"))
result = Types.TIME;
else if (ojbType.equals("timestamp"))
result = Types.TIMESTAMP;
else if (ojbType.equals("binary"))
result = Types.BINARY;
else if (ojbType.equals("varbinary"))
result = Types.VARBINARY;
else if (ojbType.equals("longvarbinary"))
result = Types.LONGVARBINARY;
else if (ojbType.equals("clob"))
result = Types.CLOB;
else if (ojbType.equals("blob"))
result = Types.BLOB;
else
throw new SQLException(
"The type '"+ ojbType + "' is not a valid jdbc type.");
return result;
} | java | {
"resource": ""
} |
q9643 | RoutingTable.addRoute | train | public void addRoute(String path, Class<? extends Actor> actorClass) throws RouteAlreadyMappedException {
addRoute(new Route(path, false), actorClass);
} | java | {
"resource": ""
} |
q9644 | RoutingTable.addRegexRoute | train | public void addRegexRoute(String urlPattern, Class<? extends Actor> actorClass) throws RouteAlreadyMappedException {
addRoute(new Route(urlPattern, true), actorClass);
} | java | {
"resource": ""
} |
q9645 | PlatformDb2Impl.setObjectForStatement | train | public void setObjectForStatement(PreparedStatement ps, int index,
Object value, int sqlType) throws SQLException
{
if (sqlType == Types.TINYINT)
{
ps.setByte(index, ((Byte) value).byteValue());
}
else
{
super.setObjectForStatement(ps, index, value, sqlType);
}
} | java | {
"resource": ""
} |
q9646 | PBBaseBeanImpl.getAllObjects | train | public Collection getAllObjects(Class target)
{
PersistenceBroker broker = getBroker();
Collection result;
try
{
Query q = new QueryByCriteria(target);
result = broker.getCollectionByQuery(q);
}
finally
{
if (broker != null) broker.close();
}
return result;
} | java | {
"resource": ""
} |
q9647 | PBBaseBeanImpl.deleteObject | train | public void deleteObject(Object object)
{
PersistenceBroker broker = null;
try
{
broker = getBroker();
broker.delete(object);
}
finally
{
if (broker != null) broker.close();
}
} | java | {
"resource": ""
} |
q9648 | DatabaseImpl.bind | train | public void bind(Object object, String name)
throws ObjectNameNotUniqueException
{
/**
* Is DB open? ODMG 3.0 says it has to be to call bind.
*/
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open. Must have an open DB to call bind.");
}
/**
* Is Tx open? ODMG 3.0 says it has to be to call bind.
*/
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("Tx is not open. Must have an open TX to call bind.");
}
tx.getNamedRootsMap().bind(object, name);
} | java | {
"resource": ""
} |
q9649 | DatabaseImpl.lookup | train | public Object lookup(String name) throws ObjectNameNotFoundException
{
/**
* Is DB open? ODMG 3.0 says it has to be to call bind.
*/
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open. Must have an open DB to call lookup");
}
/**
* Is Tx open? ODMG 3.0 says it has to be to call bind.
*/
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("Tx is not open. Must have an open TX to call lookup.");
}
return tx.getNamedRootsMap().lookup(name);
} | java | {
"resource": ""
} |
q9650 | DatabaseImpl.unbind | train | public void unbind(String name) throws ObjectNameNotFoundException
{
/**
* Is DB open? ODMG 3.0 says it has to be to call unbind.
*/
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open. Must have an open DB to call unbind");
}
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("Tx is not open. Must have an open TX to call lookup.");
}
tx.getNamedRootsMap().unbind(name);
} | java | {
"resource": ""
} |
q9651 | DatabaseImpl.deletePersistent | train | public void deletePersistent(Object object)
{
if (!this.isOpen())
{
throw new DatabaseClosedException("Database is not open");
}
TransactionImpl tx = getTransaction();
if (tx == null || !tx.isOpen())
{
throw new TransactionNotInProgressException("No transaction in progress, cannot delete persistent");
}
RuntimeObject rt = new RuntimeObject(object, tx);
tx.deletePersistent(rt);
// tx.moveToLastInOrderList(rt.getIdentity());
} | java | {
"resource": ""
} |
q9652 | SqlMNStatement.appendWhereClause | train | protected void appendWhereClause(StringBuffer stmt, Object[] columns)
{
stmt.append(" WHERE ");
for (int i = 0; i < columns.length; i++)
{
if (i > 0)
{
stmt.append(" AND ");
}
stmt.append(columns[i]);
stmt.append("=?");
}
} | java | {
"resource": ""
} |
q9653 | FoundationRollEventListener.logState | train | private void logState(final FileRollEvent fileRollEvent) {
// if (ApplicationState.isApplicationStateEnabled()) {
synchronized (this) {
final Collection<ApplicationState.ApplicationStateMessage> entries = ApplicationState.getAppStateEntries();
for (ApplicationState.ApplicationStateMessage entry : entries) {
Level level = ApplicationState.getLog4jLevel(entry.getLevel());
if(level.isGreaterOrEqual(ApplicationState.LOGGER.getEffectiveLevel())) {
final org.apache.log4j.spi.LoggingEvent loggingEvent = new org.apache.log4j.spi.LoggingEvent(ApplicationState.FQCN, ApplicationState.LOGGER, level, entry.getMessage(), null);
//Save the current layout before changing it to the original (relevant for marker cases when the layout was changed)
Layout current=fileRollEvent.getSource().getLayout();
//fileRollEvent.getSource().activeOriginalLayout();
String flowContext = (String) MDC.get("flowCtxt");
MDC.remove("flowCtxt");
//Write applicationState:
if(fileRollEvent.getSource().isAddApplicationState() && fileRollEvent.getSource().getFile().endsWith("log")){
fileRollEvent.dispatchToAppender(loggingEvent);
}
//Set current again.
fileRollEvent.getSource().setLayout(current);
if (flowContext != null) {
MDC.put("flowCtxt", flowContext);
}
}
}
}
// }
} | java | {
"resource": ""
} |
q9654 | ManyToOneAttribute.setBooleanAttribute | train | public void setBooleanAttribute(String name, Boolean value) {
ensureValue();
Attribute attribute = new BooleanAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9655 | ManyToOneAttribute.setFloatAttribute | train | public void setFloatAttribute(String name, Float value) {
ensureValue();
Attribute attribute = new FloatAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9656 | ManyToOneAttribute.setIntegerAttribute | train | public void setIntegerAttribute(String name, Integer value) {
ensureValue();
Attribute attribute = new IntegerAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9657 | ManyToOneAttribute.setLongAttribute | train | public void setLongAttribute(String name, Long value) {
ensureValue();
Attribute attribute = new LongAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9658 | ManyToOneAttribute.setShortAttribute | train | public void setShortAttribute(String name, Short value) {
ensureValue();
Attribute attribute = new ShortAttribute(value);
attribute.setEditable(isEditable(name));
getValue().getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9659 | OjbMetaTreeNode.load | train | public boolean load()
{
_load();
java.util.Iterator it = this.alChildren.iterator();
while (it.hasNext())
{
Object o = it.next();
if (o instanceof OjbMetaTreeNode) ((OjbMetaTreeNode)o).load();
}
return true;
} | java | {
"resource": ""
} |
q9660 | AssociationValue.getAttributes | train | @Deprecated
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map<String, PrimitiveAttribute<?>> getAttributes() {
if (!isPrimitiveOnly()) {
throw new UnsupportedOperationException("Primitive API not supported for nested association values");
}
return (Map) attributes;
} | java | {
"resource": ""
} |
q9661 | AssociationValue.setAttributes | train | @Deprecated
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setAttributes(Map<String, PrimitiveAttribute<?>> attributes) {
if (!isPrimitiveOnly()) {
throw new UnsupportedOperationException("Primitive API not supported for nested association values");
}
this.attributes = (Map) attributes;
} | java | {
"resource": ""
} |
q9662 | AssociationValue.getAttributeValue | train | public Object getAttributeValue(String attributeName) {
Attribute attribute = getAllAttributes().get(attributeName);
if (attribute != null) {
return attribute.getValue();
}
return null;
} | java | {
"resource": ""
} |
q9663 | AssociationValue.setDateAttribute | train | public void setDateAttribute(String name, Date value) {
ensureAttributes();
Attribute attribute = new DateAttribute(value);
attribute.setEditable(isEditable(name));
getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9664 | AssociationValue.setDoubleAttribute | train | public void setDoubleAttribute(String name, Double value) {
ensureAttributes();
Attribute attribute = new DoubleAttribute(value);
attribute.setEditable(isEditable(name));
getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9665 | AssociationValue.setManyToOneAttribute | train | public void setManyToOneAttribute(String name, AssociationValue value) {
ensureAttributes();
Attribute attribute = new ManyToOneAttribute(value);
attribute.setEditable(isEditable(name));
getAllAttributes().put(name, attribute);
} | java | {
"resource": ""
} |
q9666 | RasterLayerComponentImpl.addImage | train | protected void addImage(PdfContext context, ImageResult imageResult) throws BadElementException, IOException {
Bbox imageBounds = imageResult.getRasterImage().getBounds();
float scaleFactor = (float) (72 / getMap().getRasterResolution());
float width = (float) imageBounds.getWidth() * scaleFactor;
float height = (float) imageBounds.getHeight() * scaleFactor;
// subtract screen position of lower-left corner
float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor;
// shift y to lowerleft corner, flip y to user space and subtract
// screen position of lower-left
// corner
float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor;
if (log.isDebugEnabled()) {
log.debug("adding image, width=" + width + ",height=" + height + ",x=" + x + ",y=" + y);
}
// opacity
log.debug("before drawImage");
context.drawImage(Image.getInstance(imageResult.getImage()), new Rectangle(x, y, x + width, y + height),
getSize(), getOpacity());
log.debug("after drawImage");
} | java | {
"resource": ""
} |
q9667 | RasterLayerComponentImpl.addLoadError | train | protected void addLoadError(PdfContext context, ImageException e) {
Bbox imageBounds = e.getRasterImage().getBounds();
float scaleFactor = (float) (72 / getMap().getRasterResolution());
float width = (float) imageBounds.getWidth() * scaleFactor;
float height = (float) imageBounds.getHeight() * scaleFactor;
// subtract screen position of lower-left corner
float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor;
// shift y to lower left corner, flip y to user space and subtract
// screen position of lower-left
// corner
float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor;
if (log.isDebugEnabled()) {
log.debug("adding failed message=" + width + ",height=" + height + ",x=" + x + ",y=" + y);
}
float textHeight = context.getTextSize("failed", ERROR_FONT).getHeight() * 3f;
Rectangle rec = new Rectangle(x, y, x + width, y + height);
context.strokeRectangle(rec, Color.RED, 0.5f);
context.drawText(getNlsString("RasterLayerComponent.loaderror.line1"), ERROR_FONT, new Rectangle(x, y
+ textHeight, x + width, y + height), Color.RED);
context.drawText(getNlsString("RasterLayerComponent.loaderror.line2"), ERROR_FONT, rec, Color.RED);
context.drawText(getNlsString("RasterLayerComponent.loaderror.line3"), ERROR_FONT, new Rectangle(x, y
- textHeight, x + width, y + height), Color.RED);
} | java | {
"resource": ""
} |
q9668 | MaterializationCache.doLocalClear | train | public void doLocalClear()
{
if(log.isDebugEnabled()) log.debug("Clear materialization cache");
invokeCounter = 0;
enabledReadCache = false;
objectBuffer.clear();
} | java | {
"resource": ""
} |
q9669 | CassandraServerTriggerAspect.logErrorFromThrownException | train | @AfterThrowing(pointcut = "execution(* org.apache.cassandra.thrift.CassandraServer.doInsert(..))", throwing = "throwable")
public void logErrorFromThrownException(final JoinPoint joinPoint, final Throwable throwable) {
final String className = joinPoint.getTarget().getClass().getName();
final String methodName = joinPoint.getSignature().getName();
logger.error("Could not write to cassandra! Method: " + className + "."+ methodName + "()", throwable);
} | java | {
"resource": ""
} |
q9670 | AbstractResource.getDependencyJsonModel | train | public String getDependencyJsonModel() throws IOException {
final Artifact artifact = DataModelFactory.createArtifact("","","","","","","");
return JsonUtils.serialize(DataModelFactory.createDependency(artifact, Scope.COMPILE));
} | java | {
"resource": ""
} |
q9671 | AbstractResource.getPromotionDetailsJsonModel | train | public String getPromotionDetailsJsonModel() throws IOException {
final PromotionEvaluationReport sampleReport = new PromotionEvaluationReport();
sampleReport.addMessage(String.format(TWO_PLACES, PromotionReportTranslator.UNPROMOTED_MSG, "com.acme.secure-smh:core-relay:1.2.0"), MAJOR);
sampleReport.addMessage(String.format(TWO_PLACES, PromotionReportTranslator.DO_NOT_USE_MSG, "com.google.guava:guava:20.0"), MAJOR);
sampleReport.addMessage(String.format(TWO_PLACES, PromotionReportTranslator.MISSING_LICENSE_MSG, "org.apache.maven.wagon:wagon-webdav-jackrabbit:2.12"), MINOR);
sampleReport.addMessage(String.format(TWO_PLACES, PromotionReportTranslator.UNACCEPTABLE_LICENSE_MSG,
"aopaliance:aopaliance:1.0 licensed as Attribution-ShareAlike 2.5 Generic, " +
"org.polyjdbc:polyjdbc0.7.1 licensed as Creative Commons Attribution-ShareAlike 3.0 Unported License"),
MINOR);
sampleReport.addMessage(PromotionReportTranslator.SNAPSHOT_VERSION_MSG, Tag.CRITICAL);
return JsonUtils.serialize(sampleReport);
} | java | {
"resource": ""
} |
q9672 | AbstractResource.getSearchJsonModel | train | public String getSearchJsonModel() throws IOException {
DbSearch search = new DbSearch();
search.setArtifacts(new ArrayList<>());
search.setModules(new ArrayList<>());
return JsonUtils.serialize(search);
} | java | {
"resource": ""
} |
q9673 | AbstractResource.getScopes | train | public String getScopes() {
final StringBuilder sb = new StringBuilder();
for (final Scope scope : Scope.values()) {
sb.append(scope);
sb.append(", ");
}
final String scopes = sb.toString().trim();
return scopes.substring(0, scopes.length() - 1);
} | java | {
"resource": ""
} |
q9674 | AbstractResource.getReportSamples | train | public String[] getReportSamples() {
final Map<String, String> sampleValues = new HashMap<>();
sampleValues.put("name1", "Secure Transpiler Mars");
sampleValues.put("version1", "4.7.0");
sampleValues.put("name2", "Secure Transpiler Bounty");
sampleValues.put("version2", "5.0.0");
sampleValues.put("license", "CDDL-1.1");
sampleValues.put("name", "Secure Pretender");
sampleValues.put("version", "2.7.0");
sampleValues.put("organization", "Axway");
return ReportsRegistry.allReports()
.stream()
.map(report -> ReportUtils.generateSampleRequest(report, sampleValues))
.map(request -> {
try {
String desc = "";
final Optional<Report> byId = ReportsRegistry.findById(request.getReportId());
if(byId.isPresent()) {
desc = byId.get().getDescription() + "<br/><br/>";
}
return String.format(TWO_PLACES, desc, JsonUtils.serialize(request));
} catch(IOException e) {
return "Error " + e.getMessage();
}
})
.collect(Collectors.toList())
.toArray(new String[] {});
} | java | {
"resource": ""
} |
q9675 | MockManager.startMockJadexAgent | train | public static void startMockJadexAgent(String agent_name,
String agent_path, MockConfiguration configuration,
BeastTestCase story) {
story.startAgent(agent_name, agent_path);
story.sendMessageToAgent(agent_name, SFipa.INFORM, configuration);
story.setExecutionTime(2000); // To get time to execute the DF rename goal
} | java | {
"resource": ""
} |
q9676 | Reader.changeFirstLetterToCapital | train | public static String changeFirstLetterToCapital(String word) {
char[] letras = word.toCharArray();
char a = letras[0];
letras[0] = Character.toUpperCase(a);
return new String(letras);
} | java | {
"resource": ""
} |
q9677 | Reader.changeFirstLetterToLowerCase | train | public static String changeFirstLetterToLowerCase(String word) {
char[] letras = word.toCharArray();
char a = letras[0];
letras[0] = Character.toLowerCase(a);
return new String(letras);
} | java | {
"resource": ""
} |
q9678 | Reader.createClassName | train | public static String createClassName(String scenarioDescription) {
String[] words = scenarioDescription.trim().split(" ");
String name = "";
for (int i = 0; i < words.length; i++) {
name += changeFirstLetterToCapital(words[i]);
}
return name;
} | java | {
"resource": ""
} |
q9679 | Reader.createFirstLowCaseName | train | public static String createFirstLowCaseName(String scenarioDescription) {
String[] words = scenarioDescription.trim().split(" ");
String name = "";
for (int i = 0; i < words.length; i++) {
name += changeFirstLetterToCapital(words[i]);
}
return changeFirstLetterToLowerCase(name);
} | java | {
"resource": ""
} |
q9680 | Reader.fileDoesNotExist | train | protected static boolean fileDoesNotExist(String file, String path,
String dest_dir) {
File f = new File(dest_dir);
if (!f.isDirectory())
return false;
String folderPath = createFolderPath(path);
f = new File(f, folderPath);
File javaFile = new File(f, file);
boolean result = !javaFile.exists();
return result;
} | java | {
"resource": ""
} |
q9681 | Reader.createFolder | train | public static File createFolder(String path, String dest_dir)
throws BeastException {
File f = new File(dest_dir);
if (!f.isDirectory()) {
try {
f.mkdirs();
} catch (Exception e) {
logger.severe("Problem creating directory: " + path
+ File.separator + dest_dir);
}
}
String folderPath = createFolderPath(path);
f = new File(f, folderPath);
if (!f.isDirectory()) {
try {
f.mkdirs();
} catch (Exception e) {
String message = "Problem creating directory: " + path
+ File.separator + dest_dir;
logger.severe(message);
throw new BeastException(message, e);
}
}
return f;
} | java | {
"resource": ""
} |
q9682 | Reader.createFolderPath | train | public static String createFolderPath(String path) {
String[] pathParts = path.split("\\.");
String path2 = "";
for (String part : pathParts) {
if (path2.equals("")) {
path2 = part;
} else {
path2 = path2 + File.separator
+ changeFirstLetterToLowerCase(createClassName(part));
}
}
return path2;
} | java | {
"resource": ""
} |
q9683 | Reader.createFileReader | train | protected static BufferedReader createFileReader(String file_name)
throws BeastException {
try {
return new BufferedReader(new FileReader(file_name));
} catch (FileNotFoundException e) {
Logger logger = Logger.getLogger(MASReader.class.getName());
logger.severe("ERROR: " + e.toString());
throw new BeastException("ERROR: " + e.toString(), e);
}
} | java | {
"resource": ""
} |
q9684 | Reader.createDotStoryFile | train | public static void createDotStoryFile(String scenarioName,
String srcTestRootFolder, String packagePath,
String givenDescription, String whenDescription,
String thenDescription) throws BeastException {
String[] folders = packagePath.split(".");
for (String folder : folders) {
srcTestRootFolder += "/" + folder;
}
FileWriter writer = createFileWriter(createDotStoryName(scenarioName),
packagePath, srcTestRootFolder);
try {
writer.write("Scenario: " + scenarioName + "\n");
writer.write("Given " + givenDescription + "\n");
writer.write("When " + whenDescription + "\n");
writer.write("Then " + thenDescription + "\n");
writer.close();
} catch (Exception e) {
String message = "Unable to write the .story file for the scenario "
+ scenarioName;
logger.severe(message);
logger.severe(e.getMessage());
throw new BeastException(message, e);
}
} | java | {
"resource": ""
} |
q9685 | Reader.createFileWriter | train | protected static FileWriter createFileWriter(String scenarioName,
String aux_package_path, String dest_dir) throws BeastException {
try {
return new FileWriter(new File(createFolder(aux_package_path,
dest_dir), scenarioName + ".story"));
} catch (IOException e) {
String message = "ERROR writing the " + scenarioName
+ ".story file: " + e.toString();
logger.severe(message);
throw new BeastException(message, e);
}
} | java | {
"resource": ""
} |
q9686 | Reader.createDotStoryName | train | protected static String createDotStoryName(String scenarioName) {
String[] words = scenarioName.trim().split(" ");
String result = "";
for (int i = 0; i < words.length; i++) {
String word1 = words[i];
String word2 = word1.toLowerCase();
if (!word1.equals(word2)) {
String finalWord = "";
for (int j = 0; j < word1.length(); j++) {
if (i != 0) {
char c = word1.charAt(j);
if (Character.isUpperCase(c)) {
if (j==0) {
finalWord += Character.toLowerCase(c);
} else {
finalWord += "_" + Character.toLowerCase(c);
}
} else {
finalWord += c;
}
} else {
finalWord = word2;
break;
}
}
result += finalWord;
} else {
result += word2;
}
// I don't add the '_' to the last word.
if (!(i == words.length - 1))
result += "_";
}
return result;
} | java | {
"resource": ""
} |
q9687 | BasePrefetcher.buildPrefetchCriteriaMultipleKeys | train | private Criteria buildPrefetchCriteriaMultipleKeys(Collection ids, FieldDescriptor fields[])
{
Criteria crit = new Criteria();
Iterator iter = ids.iterator();
Object[] val;
Identity id;
while (iter.hasNext())
{
Criteria c = new Criteria();
id = (Identity) iter.next();
val = id.getPrimaryKeyValues();
for (int i = 0; i < val.length; i++)
{
if (val[i] == null)
{
c.addIsNull(fields[i].getAttributeName());
}
else
{
c.addEqualTo(fields[i].getAttributeName(), val[i]);
}
}
crit.addOrCriteria(c);
}
return crit;
} | java | {
"resource": ""
} |
q9688 | PersistenceBrokerThreadMapping.setCurrentPersistenceBroker | train | public static void setCurrentPersistenceBroker(PBKey key, PersistenceBrokerInternal broker)
throws PBFactoryException
{
HashMap map = (HashMap) currentBrokerMap.get();
WeakHashMap set = null;
if(map == null)
{
map = new HashMap();
currentBrokerMap.set(map);
synchronized(lock) {
loadedHMs.add(map);
}
}
else
{
set = (WeakHashMap) map.get(key);
}
if(set == null)
{
// We emulate weak HashSet using WeakHashMap
set = new WeakHashMap();
map.put(key, set);
}
set.put(broker, null);
} | java | {
"resource": ""
} |
q9689 | PersistenceBrokerThreadMapping.unsetCurrentPersistenceBroker | train | public static void unsetCurrentPersistenceBroker(PBKey key, PersistenceBrokerInternal broker)
throws PBFactoryException
{
HashMap map = (HashMap) currentBrokerMap.get();
WeakHashMap set = null;
if(map != null)
{
set = (WeakHashMap) map.get(key);
if(set != null)
{
set.remove(broker);
if(set.isEmpty())
{
map.remove(key);
}
}
if(map.isEmpty())
{
currentBrokerMap.set(null);
synchronized(lock) {
loadedHMs.remove(map);
}
}
}
} | java | {
"resource": ""
} |
q9690 | ActionOpenDatabase.actionPerformed | train | public void actionPerformed(java.awt.event.ActionEvent actionEvent)
{
new Thread()
{
public void run()
{
final java.sql.Connection conn = new JDlgDBConnection(containingFrame, false).showAndReturnConnection();
if (conn != null)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JIFrmDatabase frm = new JIFrmDatabase(conn);
containingFrame.getContentPane().add(frm);
frm.setVisible(true);
}
});
}
}
}.start();
} | java | {
"resource": ""
} |
q9691 | UserInfo.setRoles | train | public void setRoles(List<NamedRoleInfo> roles) {
this.roles = roles;
List<AuthorizationInfo> authorizations = new ArrayList<AuthorizationInfo>();
for (NamedRoleInfo role : roles) {
authorizations.addAll(role.getAuthorizations());
}
super.setAuthorizations(authorizations);
} | java | {
"resource": ""
} |
q9692 | TileUtil.getTileLayerSize | train | public static double[] getTileLayerSize(TileCode code, Envelope maxExtent, double scale) {
double div = Math.pow(2, code.getTileLevel());
double tileWidth = Math.ceil((scale * maxExtent.getWidth()) / div) / scale;
double tileHeight = Math.ceil((scale * maxExtent.getHeight()) / div) / scale;
return new double[] { tileWidth, tileHeight };
} | java | {
"resource": ""
} |
q9693 | TileUtil.getTileScreenSize | train | public static int[] getTileScreenSize(double[] worldSize, double scale) {
int screenWidth = (int) Math.round(scale * worldSize[0]);
int screenHeight = (int) Math.round(scale * worldSize[1]);
return new int[] { screenWidth, screenHeight };
} | java | {
"resource": ""
} |
q9694 | TileUtil.getTileBounds | train | public static Envelope getTileBounds(TileCode code, Envelope maxExtent, double scale) {
double[] layerSize = getTileLayerSize(code, maxExtent, scale);
if (layerSize[0] == 0) {
return null;
}
double cX = maxExtent.getMinX() + code.getX() * layerSize[0];
double cY = maxExtent.getMinY() + code.getY() * layerSize[1];
return new Envelope(cX, cX + layerSize[0], cY, cY + layerSize[1]);
} | java | {
"resource": ""
} |
q9695 | ReferenceDescriptorConstraints.check | train | public void check(ReferenceDescriptorDef refDef, String checkLevel) throws ConstraintException
{
ensureClassRef(refDef, checkLevel);
checkProxyPrefetchingLimit(refDef, checkLevel);
} | java | {
"resource": ""
} |
q9696 | SecurityServiceInfo.postConstruct | train | @PostConstruct
protected void postConstruct() {
if (null == authenticationServices) {
authenticationServices = new ArrayList<AuthenticationService>();
}
if (!excludeDefault) {
authenticationServices.add(staticAuthenticationService);
}
} | java | {
"resource": ""
} |
q9697 | OjbMemberTagsHandler.getMemberName | train | public static String getMemberName() throws XDocletException
{
if (getCurrentField() != null) {
return getCurrentField().getName();
}
else if (getCurrentMethod() != null) {
return MethodTagsHandler.getPropertyNameFor(getCurrentMethod());
}
else {
return null;
}
} | java | {
"resource": ""
} |
q9698 | OjbMemberTagsHandler.getMemberType | train | public static XClass getMemberType() throws XDocletException
{
if (getCurrentField() != null) {
return getCurrentField().getType();
}
else if (getCurrentMethod() != null) {
XMethod method = getCurrentMethod();
if (MethodTagsHandler.isGetterMethod(method)) {
return method.getReturnType().getType();
}
else if (MethodTagsHandler.isSetterMethod(method)) {
XParameter param = (XParameter)method.getParameters().iterator().next();
return param.getType();
}
}
return null;
} | java | {
"resource": ""
} |
q9699 | OjbMemberTagsHandler.getMemberDimension | train | public static int getMemberDimension() throws XDocletException
{
if (getCurrentField() != null) {
return getCurrentField().getDimension();
}
else if (getCurrentMethod() != null) {
XMethod method = getCurrentMethod();
if (MethodTagsHandler.isGetterMethod(method)) {
return method.getReturnType().getDimension();
}
else if (MethodTagsHandler.isSetterMethod(method)) {
XParameter param = (XParameter)method.getParameters().iterator().next();
return param.getDimension();
}
}
return 0;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.