_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18700 | AbstractDatabase.updateColumn | train | public T updateColumn(final Connection _con,
final String _tableName,
final String _columnName,
final ColumnType _columnType,
final int _length,
final int _scale)
throws SQLException
{
final StringBuilder cmd = new StringBuilder();
cmd.append("alter table ").append(getTableQuote()).append(_tableName).append(getTableQuote())
.append(getAlterColumn(_columnName, _columnType));
if (_length > 0) {
cmd.append("(").append(_length);
if (_scale > 0) {
cmd.append(",").append(_scale);
}
cmd.append(")");
}
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
@SuppressWarnings("unchecked")
final T ret = (T) this;
return ret;
} | java | {
"resource": ""
} |
q18701 | AbstractDatabase.addUniqueKey | train | public T addUniqueKey(final Connection _con,
final String _tableName,
final String _uniqueKeyName,
final String _columns)
throws SQLException
{
final StringBuilder cmd = new StringBuilder();
cmd.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_uniqueKeyName).append(" ")
.append("unique(").append(_columns).append(")");
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
@SuppressWarnings("unchecked") final T ret = (T) this;
return ret;
} | java | {
"resource": ""
} |
q18702 | AbstractDatabase.addForeignKey | train | public T addForeignKey(final Connection _con,
final String _tableName,
final String _foreignKeyName,
final String _key,
final String _reference,
final boolean _cascade)
throws InstallationException
{
final StringBuilder cmd = new StringBuilder()
.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_foreignKeyName).append(" ")
.append("foreign key(").append(_key).append(") ")
.append("references ").append(_reference);
if (_cascade) {
cmd.append(" on delete cascade");
}
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
try {
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
} catch (final SQLException e) {
throw new InstallationException("Foreign key could not be created. SQL statement was:\n"
+ cmd.toString(), e);
}
@SuppressWarnings("unchecked")
final T ret = (T) this;
return ret;
} | java | {
"resource": ""
} |
q18703 | AbstractDatabase.addCheckKey | train | public void addCheckKey(final Connection _con,
final String _tableName,
final String _checkKeyName,
final String _condition)
throws SQLException
{
final StringBuilder cmd = new StringBuilder()
.append("alter table ").append(_tableName).append(" ")
.append("add constraint ").append(_checkKeyName).append(" ")
.append("check(").append(_condition).append(")");
AbstractDatabase.LOG.debug(" ..SQL> " + cmd.toString());
// excecute statement
final Statement stmt = _con.createStatement();
try {
stmt.execute(cmd.toString());
} finally {
stmt.close();
}
} | java | {
"resource": ""
} |
q18704 | AbstractDatabase.findByClassName | train | public static AbstractDatabase<?> findByClassName(final String _dbClassName)
throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
return (AbstractDatabase<?>) Class.forName(_dbClassName).newInstance();
} | java | {
"resource": ""
} |
q18705 | AttachmentController.upload | train | private Collection<Observable<Attachment>> upload(RxComapiClient client, List<Attachment> data) {
Collection<Observable<Attachment>> obsList = new ArrayList<>();
for (Attachment a : data) {
obsList.add(upload(client, a));
}
return obsList;
} | java | {
"resource": ""
} |
q18706 | AttachmentController.upload | train | private Observable<Attachment> upload(RxComapiClient client, Attachment a) {
return client.service().messaging().uploadContent(a.getFolder(), a.getData())
.map(response -> a.updateWithUploadDetails(response.getResult()))
.doOnError(t -> log.e("Error uploading attachment. " + t.getLocalizedMessage()))
.onErrorReturn(a::setError);
} | java | {
"resource": ""
} |
q18707 | Ortho.set | train | public void set(double left, double right,
double bottom, double top,
double near, double far) {
this.left = left;
this.right = right;
this.bottom = bottom;
this.top = top;
this.near = near;
this.far = far;
} | java | {
"resource": ""
} |
q18708 | EQL.getStatement | train | public static AbstractStmt getStatement(final CharSequence _stmt)
{
AbstractStmt ret = null;
final IStatement<?> stmt = parse(_stmt);
if (stmt instanceof IPrintStatement) {
ret = PrintStmt.get((IPrintStatement<?>) stmt);
} else if (stmt instanceof IDeleteStatement) {
ret = DeleteStmt.get((IDeleteStatement<?>) stmt);
} else if (stmt instanceof IInsertStatement) {
ret = InsertStmt.get((IInsertStatement) stmt);
} else if (stmt instanceof IUpdateStatement) {
ret = UpdateStmt.get((IUpdateStatement<?>) stmt);
}
return ret;
} | java | {
"resource": ""
} |
q18709 | QueryBldrUtil.getInstances | train | public static List<Instance> getInstances(final AbstractQueryPart _queryPart)
throws EFapsException
{
return getQueryBldr(_queryPart).getQuery().execute();
} | java | {
"resource": ""
} |
q18710 | DecimalType.parseLocalized | train | public static BigDecimal parseLocalized(final String _value) throws EFapsException
{
final DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(Context.getThreadContext()
.getLocale());
format.setParseBigDecimal(true);
try {
return (BigDecimal) format.parse(_value);
} catch (final ParseException e) {
throw new EFapsException(DecimalType.class, "ParseException", e);
}
} | java | {
"resource": ""
} |
q18711 | JCacheService.update | train | public void update(String cacheName, Cache cache) {
cacheManager.enableManagement(cacheName, cache.isManagementEnabled());
updateStatistics(cacheName, cache);
} | java | {
"resource": ""
} |
q18712 | JCacheService.setStatistics | train | public void setStatistics(boolean enabled) {
all().forEach(cache -> updateStatistics(cache.getName(), new Cache(false, enabled)));
} | java | {
"resource": ""
} |
q18713 | JCacheService.getStatistics | train | public Optional<CacheStatistics> getStatistics(String cacheName) {
javax.cache.Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return Optional.empty();
}
if (((CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class)).isStatisticsEnabled() && cache instanceof ICache) {
com.hazelcast.cache.CacheStatistics stats = ((ICache) cache).getLocalCacheStatistics();
CacheStatistics statistics = new CacheStatistics(
stats.getCacheHits(),
stats.getCacheMisses(),
stats.getCacheHitPercentage(),
stats.getCacheMissPercentage(),
stats.getCacheGets(),
stats.getCachePuts(),
stats.getCacheRemovals(),
stats.getCacheEvictions(),
stats.getAverageGetTime(),
stats.getAveragePutTime(),
stats.getAverageRemoveTime());
return Optional.of(statistics);
}
return Optional.empty();
} | java | {
"resource": ""
} |
q18714 | Person.setAttrValue | train | private void setAttrValue(final AttrName _attrName,
final String _value)
{
synchronized (this.attrValues) {
this.attrValues.put(_attrName, _value);
}
} | java | {
"resource": ""
} |
q18715 | Person.getLocale | train | public Locale getLocale()
{
final Locale ret;
if (this.attrValues.get(Person.AttrName.LOCALE) != null) {
final String localeStr = this.attrValues.get(Person.AttrName.LOCALE);
final String[] countries = localeStr.split("_");
if (countries.length == 2) {
ret = new Locale(countries[0], countries[1]);
} else if (countries.length == 3) {
ret = new Locale(countries[0], countries[1], countries[2]);
} else {
ret = new Locale(localeStr);
}
} else {
ret = Locale.ENGLISH;
}
return ret;
} | java | {
"resource": ""
} |
q18716 | Person.getLanguage | train | public String getLanguage()
{
return this.attrValues.get(Person.AttrName.LANGUAGE) != null
? this.attrValues.get(Person.AttrName.LANGUAGE)
: Locale.ENGLISH.getISO3Language();
} | java | {
"resource": ""
} |
q18717 | Person.getTimeZone | train | public DateTimeZone getTimeZone()
{
return this.attrValues.get(Person.AttrName.TIMZONE) != null
? DateTimeZone.forID(this.attrValues.get(Person.AttrName.TIMZONE))
: DateTimeZone.UTC;
} | java | {
"resource": ""
} |
q18718 | Person.getChronologyType | train | public ChronologyType getChronologyType()
{
final String chronoKey = this.attrValues.get(Person.AttrName.CHRONOLOGY);
final ChronologyType chronoType;
if (chronoKey != null) {
chronoType = ChronologyType.getByKey(chronoKey);
} else {
chronoType = ChronologyType.ISO8601;
}
return chronoType;
} | java | {
"resource": ""
} |
q18719 | Person.checkPassword | train | public boolean checkPassword(final String _passwd)
throws EFapsException
{
boolean ret = false;
final PrintQuery query = new PrintQuery(CIAdminUser.Person.getType(), getId());
query.addAttribute(CIAdminUser.Person.Password,
CIAdminUser.Person.LastLogin,
CIAdminUser.Person.LoginTry,
CIAdminUser.Person.LoginTriesCounter,
CIAdminUser.Person.Status);
if (query.executeWithoutAccessCheck()) {
final PasswordStore pwd = query.<PasswordStore>getAttribute(CIAdminUser.Person.Password);
if (pwd.checkCurrent(_passwd)) {
ret = query.<Boolean>getAttribute(CIAdminUser.Person.Status);
} else {
setFalseLogin(query.<DateTime>getAttribute(CIAdminUser.Person.LoginTry),
query.<Integer>getAttribute(CIAdminUser.Person.LoginTriesCounter));
}
}
return ret;
} | java | {
"resource": ""
} |
q18720 | Person.setFalseLogin | train | private void setFalseLogin(final DateTime _logintry,
final int _count)
throws EFapsException
{
if (_count > 0) {
final DateTime now = new DateTime(DateTimeUtil.getCurrentTimeFromDB().getTime());
final SystemConfiguration kernelConfig = EFapsSystemConfiguration.get();
final int minutes = kernelConfig.getAttributeValueAsInteger(KernelSettings.LOGIN_TIME_RETRY);
final int maxtries = kernelConfig.getAttributeValueAsInteger(KernelSettings.LOGIN_MAX_TRIES);
final int count = _count + 1;
if (minutes > 0 && _logintry.minusMinutes(minutes).isBefore(now)) {
updateFalseLoginDB(1);
} else {
updateFalseLoginDB(count);
}
if (maxtries > 0 && count > maxtries && getStatus()) {
setStatusInDB(false);
}
} else {
updateFalseLoginDB(1);
}
} | java | {
"resource": ""
} |
q18721 | Person.updateFalseLoginDB | train | private void updateFalseLoginDB(final int _tries)
throws EFapsException
{
Connection con = null;
try {
con = Context.getConnection();
Statement stmt = null;
final StringBuilder cmd = new StringBuilder();
try {
cmd.append("update T_USERPERSON ").append("set LOGINTRY=").append(
Context.getDbType().getCurrentTimeStamp()).append(", LOGINTRIES=").append(_tries)
.append(" where ID=").append(getId());
stmt = con.createStatement();
final int rows = stmt.executeUpdate(cmd.toString());
if (rows == 0) {
Person.LOG.error("could not execute '" + cmd.toString()
+ "' to update last login information for person '" + toString() + "'");
throw new EFapsException(getClass(), "updateLastLogin.NotUpdated", cmd.toString(), getName());
}
} catch (final SQLException e) {
Person.LOG.error("could not execute '" + cmd.toString()
+ "' to update last login information for person '" + toString() + "'", e);
throw new EFapsException(getClass(), "updateLastLogin.SQLException", e, cmd.toString(), getName());
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (final SQLException e) {
throw new EFapsException(getClass(), "updateLastLogin.SQLException", e, cmd.toString(), getName());
}
}
con.commit();
con.close();
} catch (final SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} | java | {
"resource": ""
} |
q18722 | Person.setPassword | train | public Status setPassword(final String _newPasswd)
throws EFapsException
{
final Type type = CIAdminUser.Person.getType();
if (_newPasswd.length() == 0) {
throw new EFapsException(getClass(), "PassWordLength", 1, _newPasswd.length());
}
final Update update = new Update(type, "" + getId());
final Status status = update.add(CIAdminUser.Person.Password, _newPasswd);
if (status.isOk()) {
update.execute();
update.close();
} else {
Person.LOG.error("Password could not be set by the Update, due to restrictions " + "e.g. length???");
throw new EFapsException(getClass(), "TODO");
}
return status;
} | java | {
"resource": ""
} |
q18723 | Person.readFromDB | train | protected void readFromDB()
throws EFapsException
{
readFromDBAttributes();
this.roles.clear();
for (final Role role : getRolesFromDB()) {
add(role);
}
this.groups.clear();
for (final Group group : getGroupsFromDB(null)) {
add(group);
}
this.companies.clear();
for (final Company company : getCompaniesFromDB(null)) {
add(company);
}
this.associations.clear();
for (final Association association : getAssociationsFromDB(null)) {
add(association);
}
} | java | {
"resource": ""
} |
q18724 | Person.readFromDBAttributes | train | private void readFromDBAttributes()
throws EFapsException
{
Connection con = null;
try {
con = Context.getConnection();
Statement stmt = null;
try {
stmt = con.createStatement();
final StringBuilder cmd = new StringBuilder("select ");
for (final AttrName attrName : Person.AttrName.values()) {
cmd.append(attrName.sqlColumn).append(",");
}
cmd.append("0 as DUMMY ").append("from V_USERPERSON ").append("where V_USERPERSON.ID=").append(getId());
final ResultSet resultset = stmt.executeQuery(cmd.toString());
if (resultset.next()) {
for (final AttrName attrName : Person.AttrName.values()) {
final String tmp = resultset.getString(attrName.sqlColumn);
setAttrValue(attrName, tmp == null ? null : tmp.trim());
}
}
resultset.close();
} catch (final SQLException e) {
Person.LOG.error("read attributes for person with SQL statement is not " + "possible", e);
throw new EFapsException(Person.class, "readFromDBAttributes.SQLException", e, getName(), getId());
} finally {
try {
if (stmt != null) {
stmt.close();
}
con.commit();
} catch (final SQLException e) {
Person.LOG.error("close of SQL statement is not possible", e);
}
}
} finally {
try {
if (con != null && !con.isClosed()) {
con.close();
}
} catch (final SQLException e) {
throw new CacheReloadException("could not read child type ids", e);
}
}
} | java | {
"resource": ""
} |
q18725 | Person.setGroups | train | public void setGroups(final JAASSystem _jaasSystem,
final Set<Group> _groups)
throws EFapsException
{
if (_jaasSystem == null) {
throw new EFapsException(getClass(), "setGroups.nojaasSystem", getName());
}
if (_groups == null) {
throw new EFapsException(getClass(), "setGroups.noGroups", getName());
}
for (final Group group : _groups) {
add(group);
}
// current groups
final Set<Group> groupsInDb = getGroupsFromDB(_jaasSystem);
// compare new roles with current groups (add missing groups)
for (final Group group : _groups) {
if (!groupsInDb.contains(group)) {
assignGroupInDb(_jaasSystem, group);
}
}
// compare current roles with new groups (remove groups which are to
// much)
for (final Group group : groupsInDb) {
if (!_groups.contains(group)) {
unassignGroupInDb(_jaasSystem, group);
}
}
} | java | {
"resource": ""
} |
q18726 | Person.assignGroupInDb | train | public void assignGroupInDb(final JAASSystem _jaasSystem,
final Group _group)
throws EFapsException
{
assignToUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group);
} | java | {
"resource": ""
} |
q18727 | Person.unassignGroupInDb | train | public void unassignGroupInDb(final JAASSystem _jaasSystem,
final Group _group)
throws EFapsException
{
unassignFromUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group);
} | java | {
"resource": ""
} |
q18728 | Person.reset | train | public static void reset(final String _key)
throws EFapsException
{
final Person person;
if (UUIDUtil.isUUID(_key)) {
person = Person.get(UUID.fromString(_key));
} else {
person = Person.get(_key);
}
if (person != null) {
InfinispanCache.get().<Long, Person>getCache(Person.IDCACHE).remove(person.getId());
InfinispanCache.get().<String, Person>getCache(Person.NAMECACHE).remove(person.getName());
if (person.getUUID() != null) {
InfinispanCache.get().<UUID, Person>getCache(Person.UUIDCACHE).remove(person.getUUID());
}
}
} | java | {
"resource": ""
} |
q18729 | MessageProcessor.preparePostUpload | train | public void preparePostUpload(final List<Attachment> attachments) {
tempParts.clear();
if (!attachments.isEmpty()) {
for (Attachment a : attachments) {
if (a.getError() != null) {
errorParts.add(createErrorPart(a));
} else {
publicParts.add(createPart(a));
}
}
}
} | java | {
"resource": ""
} |
q18730 | MessageProcessor.createErrorPart | train | private Part createErrorPart(Attachment a) {
return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_ERROR).setUrl(null).setData(a.getError().getLocalizedMessage()).build();
} | java | {
"resource": ""
} |
q18731 | MessageProcessor.createTempPart | train | private Part createTempPart(Attachment a) {
return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_UPLOADING).setUrl(null).setData(null).build();
} | java | {
"resource": ""
} |
q18732 | MessageProcessor.createPart | train | private Part createPart(Attachment a) {
return Part.builder().setName(a.getName() != null ? a.getName() : a.getId()).setSize(a.getSize()).setType(a.getType()).setUrl(a.getUrl()).build();
} | java | {
"resource": ""
} |
q18733 | MessageProcessor.prepareMessageToSend | train | public MessageToSend prepareMessageToSend() {
originalMessage.getParts().clear();
originalMessage.getParts().addAll(publicParts);
return originalMessage;
} | java | {
"resource": ""
} |
q18734 | MessageProcessor.createFinalMessage | train | public ChatMessage createFinalMessage(MessageSentResponse response) {
return ChatMessage.builder()
.setMessageId(response.getId())
.setSentEventId(response.getEventId())
.setConversationId(conversationId)
.setSentBy(sender)
.setFromWhom(new Sender(sender, sender))
.setSentOn(System.currentTimeMillis())
.setParts(getAllParts())
.setMetadata(originalMessage.getMetadata()).build();
} | java | {
"resource": ""
} |
q18735 | Insert.addTables | train | private void addTables()
{
for (final SQLTable table : getType().getTables()) {
if (!getTable2values().containsKey(table)) {
getTable2values().put(table, new ArrayList<Value>());
}
}
} | java | {
"resource": ""
} |
q18736 | Insert.addCreateUpdateAttributes | train | private void addCreateUpdateAttributes() throws EFapsException
{
final Iterator<?> iter = getType().getAttributes().entrySet().iterator();
while (iter.hasNext()) {
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next();
final Attribute attr = (Attribute) entry.getValue();
final AttributeType attrType = attr.getAttributeType();
if (attrType.isCreateUpdate()) {
addInternal(attr, false, (Object) null);
}
if (attr.getDefaultValue() != null) {
addInternal(attr, false, attr.getDefaultValue());
}
}
} | java | {
"resource": ""
} |
q18737 | Insert.setExchangeIds | train | public Insert setExchangeIds(final Long _exchangeSystemId,
final Long _exchangeId)
{
this.exchangeSystemId = _exchangeSystemId;
this.exchangeId = _exchangeId;
return this;
} | java | {
"resource": ""
} |
q18738 | Insert.executeWithoutTrigger | train | @Override
public void executeWithoutTrigger()
throws EFapsException
{
final Context context = Context.getThreadContext();
ConnectionResource con = null;
try {
con = context.getConnectionResource();
final SQLTable mainTable = getType().getMainTable();
final long id = executeOneStatement(con, mainTable, getTable2values().get(mainTable), 0);
setInstance(Instance.get(getInstance().getType(), id));
getInstance().setExchangeId(this.exchangeId);
getInstance().setExchangeSystemId(this.exchangeSystemId);
GeneralInstance.insert(getInstance(), con);
for (final Entry<SQLTable, List<Value>> entry : getTable2values().entrySet()) {
final SQLTable table = entry.getKey();
if (!table.equals(mainTable) && !table.isReadOnly()) {
executeOneStatement(con, table, entry.getValue(), id);
}
}
Queue.registerUpdate(getInstance());
} finally {
}
} | java | {
"resource": ""
} |
q18739 | Random.randVertex2d | train | public static final Vector3D randVertex2d() {
float theta = random((float)(Math.PI*2.0));
return new Vector3D(Math.cos(theta),Math.sin(theta));
} | java | {
"resource": ""
} |
q18740 | ChatMessage.addStatusUpdate | train | @SuppressLint("UseSparseArrays")
public void addStatusUpdate(ChatMessageStatus status) {
int unique = (status.getMessageId() + status.getProfileId() + status.getMessageStatus().name()).hashCode();
if (statusUpdates == null) {
statusUpdates = new HashMap<>();
}
statusUpdates.put(unique, status);
} | java | {
"resource": ""
} |
q18741 | MapUtil.put | train | public static void put(Map<String,Object> structure, String name, Object object)
{
if (name != null && object != null)
{
structure.put(name, object);
}
} | java | {
"resource": ""
} |
q18742 | TedDaoMysql.createTaskInternal | train | protected long createTaskInternal(final String name, final String channel, final String data, final String key1, final String key2, final Long batchId, int postponeSec, TedStatus status) {
final String sqlLogId = "create_task";
if (status == null)
status = TedStatus.NEW;
String nextts = (status == TedStatus.NEW ? dbType.sql.now() + " + " + dbType.sql.intervalSeconds(postponeSec) : "null");
String sql = " insert into tedtask (taskId, `system`, name, channel, bno, status, createTs, nextTs, retries, data, key1, key2, batchId)" +
" values(null, '$sys', ?, ?, null, '$status', $now, $nextts, 0, ?, ?, ?, ?)" +
" ";
sql = sql.replace("$nextTaskId", dbType.sql.sequenceSql("SEQ_TEDTASK_ID"));
sql = sql.replace("$now", dbType.sql.now());
sql = sql.replace("$sys", thisSystem);
sql = sql.replace("$nextts", nextts);
sql = sql.replace("$status", status.toString());
final String finalSql = sql;
Long taskId = JdbcSelectTed.runInConn(dataSource, new ExecInConn<Long>() {
@Override
public Long execute(Connection connection) throws SQLException {
int res = JdbcSelectTedImpl.executeUpdate(connection, finalSql, asList(
sqlParam(name, JetJdbcParamType.STRING),
sqlParam(channel, JetJdbcParamType.STRING),
sqlParam(data, JetJdbcParamType.STRING),
sqlParam(key1, JetJdbcParamType.STRING),
sqlParam(key2, JetJdbcParamType.STRING),
sqlParam(batchId, JetJdbcParamType.LONG)
));
if (res != 1)
throw new IllegalStateException("expected 1 insert");
String sql = "select last_insert_id()";
return JdbcSelectTedImpl.selectSingleLong(connection, sql, Collections.<SqlParam>emptyList());
}
});
logger.trace("Task {} {} created successfully. ", name, taskId);
return taskId;
} | java | {
"resource": ""
} |
q18743 | Regex.escape | train | public static String escape(String literal)
{
StringBuilder sb = new StringBuilder();
for (int ii = 0; ii < literal.length(); ii++)
{
char cc = literal.charAt(ii);
switch (cc)
{
case '[':
case ']':
case '(':
case ')':
case '\\':
case '-':
case '^':
case '*':
case '+':
case '?':
case '|':
case '.':
case '{':
case '}':
case '&':
case '$':
case ',':
sb.append("\\").append(cc);
break;
default:
sb.append(cc);
break;
}
}
return sb.toString();
} | java | {
"resource": ""
} |
q18744 | Regex.isMatch | train | public boolean isMatch(CharSequence text)
{
try
{
if (text.length() == 0)
{
return acceptEmpty;
}
InputReader reader = Input.getInstance(text);
return isMatch(reader);
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | java | {
"resource": ""
} |
q18745 | Regex.isMatch | train | public boolean isMatch(PushbackReader input, int size) throws IOException
{
InputReader reader = Input.getInstance(input, size);
return isMatch(reader);
} | java | {
"resource": ""
} |
q18746 | Regex.isMatch | train | public boolean isMatch(InputReader reader) throws IOException
{
int rc = match(reader);
return (rc == 1 && reader.read() == -1);
} | java | {
"resource": ""
} |
q18747 | Regex.match | train | public String match(CharSequence text)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
else
{
throw new SyntaxErrorException("empty string not accepted");
}
}
InputReader reader = Input.getInstance(text);
int rc = match(reader);
if (rc == 1 && reader.read() == -1)
{
return reader.getString();
}
else
{
throw new SyntaxErrorException("syntax error"
+ "\n"
+ reader.getLineNumber() + ": " + reader.getLine()
+ "\n"
+ pointer(reader.getColumnNumber() + 2));
}
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | java | {
"resource": ""
} |
q18748 | Regex.lookingAt | train | public String lookingAt(CharSequence text)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
else
{
throw new SyntaxErrorException("empty string not accepted");
}
}
InputReader reader = Input.getInstance(text);
return lookingAt(reader);
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen");
}
} | java | {
"resource": ""
} |
q18749 | Regex.replace | train | public String replace(CharSequence text, CharSequence replacement)
{
try
{
if (text.length() == 0)
{
if (acceptEmpty)
{
return "";
}
}
CharArrayWriter caw = new CharArrayWriter();
InputReader reader = Input.getInstance(text);
ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(replacement);
replace(reader, caw, fsp);
return caw.toString();
}
catch (IOException ex)
{
throw new IllegalArgumentException("can't happen", ex);
}
} | java | {
"resource": ""
} |
q18750 | Regex.replace | train | public String replace(CharSequence text, ObsoleteReplacer replacer) throws IOException
{
if (text.length() == 0)
{
return "";
}
CharArrayWriter caw = new CharArrayWriter();
InputReader reader = Input.getInstance(text);
replace(reader, caw, replacer);
return caw.toString();
} | java | {
"resource": ""
} |
q18751 | Regex.replace | train | public void replace(PushbackReader in, int bufferSize, Writer out, String format) throws IOException
{
InputReader reader = Input.getInstance(in, bufferSize);
ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(format);
replace(reader, out, fsp);
} | java | {
"resource": ""
} |
q18752 | Regex.replace | train | public void replace(PushbackReader in, int bufferSize, Writer out, ObsoleteReplacer replacer) throws IOException
{
InputReader reader = Input.getInstance(in, bufferSize);
replace(reader, out, replacer);
} | java | {
"resource": ""
} |
q18753 | Regex.literal | train | public static Regex literal(String expression, Option... options) throws IOException
{
return compile(escape(expression), options);
} | java | {
"resource": ""
} |
q18754 | Regex.createDFA | train | public static DFA<Integer> createDFA(String expression, int reducer, Option... options)
{
NFA<Integer> nfa = createNFA(new Scope<NFAState<Integer>>(expression), expression, reducer, options);
DFA<Integer> dfa = nfa.constructDFA(new Scope<DFAState<Integer>>(expression));
return dfa;
} | java | {
"resource": ""
} |
q18755 | JdbcSelectTedImpl.executeOraBlock | train | static <T> List<T> executeOraBlock(Connection connection, String sql, Class<T> clazz, List<SqlParam> sqlParams) throws SQLException {
String cursorParam = null;
List<T> list = new ArrayList<T>();
//boolean autoCommitOrig = connection.getAutoCommit();
//if (autoCommitOrig == true) {
// connection.setAutoCommit(false); // to able to read from temp-tables
//}
CallableStatement stmt = null;
ResultSet resultSet = null;
try {
stmt = connection.prepareCall(sql);
cursorParam = stmtAssignSqlParams(stmt, sqlParams);
boolean hasRs = stmt.execute();
if (cursorParam != null) {
resultSet = (ResultSet) stmt.getObject(cursorParam);
list = resultSetToList(resultSet, clazz);
}
} finally {
try { if (resultSet != null) resultSet.close(); } catch (Exception e) {logger.error("Cannot close resultSet", e);};
//if (autoCommitOrig == true)
// connection.setAutoCommit(autoCommitOrig);
try { if (stmt != null) stmt.close(); } catch (Exception e) {logger.error("Cannot close statement", e);};
}
return list;
} | java | {
"resource": ""
} |
q18756 | PersistenceController.loadAllConversations | train | Observable<List<ChatConversationBase>> loadAllConversations() {
return Observable.create(emitter -> storeFactory.execute(new StoreTransaction<ChatStore>() {
@Override
protected void execute(ChatStore store) {
store.open();
List<ChatConversationBase> conversations = store.getAllConversations();
store.close();
emitter.onNext(conversations);
emitter.onCompleted();
}
}), Emitter.BackpressureMode.LATEST);
} | java | {
"resource": ""
} |
q18757 | PersistenceController.processOrphanedEvents | train | Observable<ComapiResult<MessagesQueryResponse>> processOrphanedEvents(ComapiResult<MessagesQueryResponse> result, final ChatController.OrphanedEventsToRemoveListener removeListener) {
if (result.isSuccessful() && result.getResult() != null) {
final MessagesQueryResponse response = result.getResult();
final List<MessageReceived> messages = response.getMessages();
final String[] ids = new String[messages.size()];
if (!messages.isEmpty()) {
for (int i = 0; i < messages.size(); i++) {
ids[i] = messages.get(i).getMessageId();
}
}
return db.save(response.getOrphanedEvents())
.flatMap(count -> db.queryOrphanedEvents(ids))
.flatMap(toDelete -> Observable.create(emitter ->
storeFactory.execute(new StoreTransaction<ChatStore>() {
@Override
protected void execute(ChatStore store) {
if (!toDelete.isEmpty()) {
storeFactory.execute(new StoreTransaction<ChatStore>() {
@Override
protected void execute(ChatStore store) {
List<ChatMessageStatus> statuses = modelAdapter.adaptEvents(toDelete);
store.beginTransaction();
if (!statuses.isEmpty()) {
for (ChatMessageStatus status : statuses) {
store.update(status);
}
}
String[] ids = new String[toDelete.size()];
for (int i = 0; i < toDelete.size(); i++) {
ids[i] = toDelete.get(i).id();
}
removeListener.remove(ids);
store.endTransaction();
emitter.onNext(result);
emitter.onCompleted();
}
});
} else {
emitter.onNext(result);
emitter.onCompleted();
}
}
}), Emitter.BackpressureMode.BUFFER));
} else {
return Observable.fromCallable(() -> result);
}
} | java | {
"resource": ""
} |
q18758 | PersistenceController.updateStoreWithNewMessage | train | public Observable<Boolean> updateStoreWithNewMessage(final ChatMessage message, final ChatController.NoConversationListener noConversationListener) {
return asObservable(new Executor<Boolean>() {
@Override
protected void execute(ChatStore store, Emitter<Boolean> emitter) {
boolean isSuccessful = true;
store.beginTransaction();
ChatConversationBase conversation = store.getConversation(message.getConversationId());
String tempId = (String) (message.getMetadata() != null ? message.getMetadata().get(MESSAGE_METADATA_TEMP_ID) : null);
if (!TextUtils.isEmpty(tempId)) {
store.deleteMessage(message.getConversationId(), tempId);
}
if (message.getSentEventId() == null) {
message.setSentEventId(-1L);
}
if (message.getSentEventId() == -1L) {
if (conversation != null && conversation.getLastLocalEventId() != -1L) {
message.setSentEventId(conversation.getLastLocalEventId() + 1);
}
message.addStatusUpdate(ChatMessageStatus.builder().populate(message.getConversationId(), message.getMessageId(), message.getFromWhom().getId(), LocalMessageStatus.sent, System.currentTimeMillis(), null).build());
isSuccessful = store.upsert(message);
} else {
isSuccessful = store.upsert(message);
}
if (!doUpdateConversationFromEvent(store, message.getConversationId(), message.getSentEventId(), message.getSentOn()) && noConversationListener != null) {
noConversationListener.getConversation(message.getConversationId());
}
store.endTransaction();
emitter.onNext(isSuccessful);
emitter.onCompleted();
}
});
} | java | {
"resource": ""
} |
q18759 | PersistenceController.updateStoreForSentError | train | public Observable<Boolean> updateStoreForSentError(String conversationId, String tempId, String profileId) {
return asObservable(new Executor<Boolean>() {
@Override
protected void execute(ChatStore store, Emitter<Boolean> emitter) {
store.beginTransaction();
boolean isSuccess = store.update(ChatMessageStatus.builder().populate(conversationId, tempId, profileId, LocalMessageStatus.error, System.currentTimeMillis(), null).build());
store.endTransaction();
emitter.onNext(isSuccess);
emitter.onCompleted();
}
});
} | java | {
"resource": ""
} |
q18760 | PersistenceController.doUpdateConversationFromEvent | train | private boolean doUpdateConversationFromEvent(ChatStore store, String conversationId, Long eventId, Long updatedOn) {
ChatConversationBase conversation = store.getConversation(conversationId);
if (conversation != null) {
ChatConversationBase.Builder builder = ChatConversationBase.baseBuilder().populate(conversation);
if (eventId != null) {
if (conversation.getLastRemoteEventId() < eventId) {
builder.setLastRemoteEventId(eventId);
}
if (conversation.getLastLocalEventId() < eventId) {
builder.setLastLocalEventId(eventId);
}
if (conversation.getFirstLocalEventId() == -1) {
builder.setFirstLocalEventId(eventId);
}
if (conversation.getUpdatedOn() < updatedOn) {
builder.setUpdatedOn(updatedOn);
}
}
return store.update(builder.build());
}
return false;
} | java | {
"resource": ""
} |
q18761 | PersistenceController.upsertConversation | train | public Observable<Boolean> upsertConversation(ChatConversation conversation) {
List<ChatConversation> conversations = new ArrayList<>();
conversations.add(conversation);
return upsertConversations(conversations);
} | java | {
"resource": ""
} |
q18762 | PersistenceController.asObservable | train | private <T> Observable<T> asObservable(Executor<T> transaction) {
return Observable.create(emitter -> storeFactory.execute(new StoreTransaction<ChatStore>() {
@Override
protected void execute(ChatStore store) {
try {
transaction.execute(store, emitter);
} finally {
emitter.onCompleted();
}
}
}), Emitter.BackpressureMode.BUFFER);
} | java | {
"resource": ""
} |
q18763 | Input.setCharset | train | @Override
public void setCharset(Charset cs, boolean fixedCharset)
{
if (includeLevel.in instanceof ModifiableCharset)
{
ModifiableCharset sr = (ModifiableCharset) includeLevel.in;
sr.setCharset(cs, fixedCharset);
}
else
{
throw new UnsupportedOperationException("setting charset not supported with current input "+includeLevel.in);
}
} | java | {
"resource": ""
} |
q18764 | Input.release | train | @Override
public void release() throws IOException
{
if (includeLevel.in != null && end != cursor)
{
if (end % size < cursor % size)
{
buffer2.position(0);
buffer2.limit((int)(end % size));
buffer1.position((int)(cursor % size));
buffer1.limit(size);
}
else
{
buffer2.position((int)(cursor % size));
buffer2.limit((int)(end % size));
buffer1.position(size);
}
if (features.contains(UsePushback))
{
if (includeLevel.in instanceof Pushbackable)
{
Pushbackable p = (Pushbackable) includeLevel.in;
p.pushback(array2);
}
else
{
unread(includeLevel.in);
}
}
else
{
if (includeLevel.in instanceof Rewindable)
{
Rewindable rewindable = (Rewindable) includeLevel.in;
rewindable.rewind((int)(end-cursor));
}
else
{
unread(includeLevel.in);
}
}
buffer1.clear();
buffer2.clear();
end = cursor;
}
} | java | {
"resource": ""
} |
q18765 | Input.peek | train | @Override
public int peek(int offset) throws IOException
{
long target = cursor + offset - 1;
if (target - end > size || target < end - size || target < 0)
{
throw new IllegalArgumentException("offset "+offset+" out of buffer");
}
if (target >= end)
{
int la = 0;
while (target >= end)
{
int cc = read();
if (cc == -1)
{
if (target+la == end)
{
return -1;
}
else
{
throw new IOException("eof");
}
}
la++;
}
rewind(la);
}
return get(target);
} | java | {
"resource": ""
} |
q18766 | Input.rewind | train | @Override
public void rewind(int count) throws IOException
{
if (count < 0)
{
throw new IllegalArgumentException("negative rewind "+count);
}
cursor -= count;
if (cursor < end - size || cursor < 0)
{
throw new IOException("insufficient room in the pushback buffer");
}
length -= count;
if (length < 0)
{
throw new IOException("rewinding past input");
}
int ld = 0;
for (int ii=0;ii<count;ii++)
{
if (get((cursor+ii)) == '\n')
{
ld++;
}
}
if (ld > 0)
{
int l = includeLevel.line;
includeLevel.line = l - ld;
int c = 0;
long start = Math.max(0, end-size);
for (long ii=cursor;ii>=start;ii--)
{
if (get(ii) == '\n')
{
break;
}
c++;
}
includeLevel.column = c;
}
else
{
int c = includeLevel.column;
includeLevel.column = c - count;
}
} | java | {
"resource": ""
} |
q18767 | Input.read | train | @Override
public final int read() throws IOException
{
assert cursor <= end;
if (cursor >= end)
{
if (includeLevel.in == null)
{
return -1;
}
int cp = (int)(cursor % size);
long len = size-(cursor-waterMark);
int il;
if (len > size - cp)
{
buffer1.position(cp);
buffer1.limit(size);
buffer2.position(0);
buffer2.limit((int)(len-(size-cp)));
if (!buffer1.hasRemaining() && !buffer2.hasRemaining())
{
throw new UnderflowException("Buffer size="+size+" too small for operation");
}
il = fill(includeLevel.in, array2);
}
else
{
buffer1.position(cp);
buffer1.limit((int)(cp+len));
if (!buffer1.hasRemaining())
{
throw new UnderflowException("Buffer size="+size+" too small for operation");
}
il = fill(includeLevel.in, array1);
}
if (il == -1)
{
if (includeStack != null)
{
while (!includeStack.isEmpty() && il == -1)
{
close(includeLevel.in);
includeLevel = includeStack.pop();
return read();
}
}
return -1;
}
if (il == 0)
{
throw new IOException("No input! Use blocking mode?");
}
buffer1.clear();
buffer2.clear();
end+=il;
if (end < 0)
{
throw new IOException("end = "+end);
}
}
int rc = get(cursor++);
if (cursor < 0)
{
throw new IOException("cursor = "+cursor);
}
includeLevel.forward(rc);
length++;
if (length > size)
{
throw new IOException("input size "+length+" exceeds buffer size "+size);
}
if (checksum != null)
{
checksum.update(cursor-1, rc);
}
return rc;
} | java | {
"resource": ""
} |
q18768 | Input.parseInt | train | @Override
public int parseInt(long s, int l, int radix)
{
return Primitives.parseInt(getCharSequence(s, l), radix);
} | java | {
"resource": ""
} |
q18769 | Compile.compile | train | @GET
public Response compile(@QueryParam("type") final String _type)
{
boolean success = false;
try {
if (hasAccess()) {
AbstractRest.LOG.info("===Starting Compiler via REST===");
if ("java".equalsIgnoreCase(_type)) {
AbstractRest.LOG.info("==Compiling Java==");
new ESJPCompiler(getClassPathElements()).compile(null, false);
} else if ("css".equalsIgnoreCase(_type)) {
AbstractRest.LOG.info("==Compiling CSS==");
new CSSCompiler().compile();
} else if ("js".equalsIgnoreCase(_type)) {
AbstractRest.LOG.info("==Compiling Javascript==");
new JavaScriptCompiler().compile();
} else if ("wiki".equalsIgnoreCase(_type)) {
AbstractRest.LOG.info("==Compiling Wiki==");
new WikiCompiler().compile();
} else if ("jasper".equalsIgnoreCase(_type)) {
AbstractRest.LOG.info("==Compiling JasperReports==");
new JasperReportCompiler(getClassPathElements()).compile();
}
success = true;
AbstractRest.LOG.info("===Ending Compiler via REST===");
}
} catch (final InstallationException e) {
AbstractRest.LOG.error("InstallationException", e);
} catch (final EFapsException e) {
AbstractRest.LOG.error("EFapsException", e);
}
return success ? Response.ok().build() : Response.noContent().build();
} | java | {
"resource": ""
} |
q18770 | NoWaitBlockingSupplier.supplierChanged | train | @Override
public void supplierChanged(SupplierEvent supplierEvent) {
SupplierEvent.Type type = supplierEvent.type();
@SuppressWarnings("unchecked")
Supplier<T> supplier = (Supplier<T>) supplierEvent.supplier();
switch (type) {
case ADD:
if (supplierReference.compareAndSet(null, supplier)) {
supplierFutureRef.get().complete(supplier);
}
break;
case REMOVE:
if (supplierReference.compareAndSet(supplier, null)) {
supplierFutureRef.set(new CompletableFuture<>());
}
break;
default:
throw new IllegalStateException("Unknown supplier event: " + supplierEvent);
}
} | java | {
"resource": ""
} |
q18771 | BooleanUI.getLabel | train | private String getLabel(final UIValue _uiValue,
final Boolean _key)
throws CacheReloadException
{
String ret = BooleanUtils.toStringTrueFalse(_key);
if (_uiValue.getAttribute() != null
&& DBProperties.hasProperty(_uiValue.getAttribute().getKey() + "."
+ BooleanUtils.toStringTrueFalse(_key))) {
ret = DBProperties.getProperty(_uiValue.getAttribute().getKey() + "."
+ BooleanUtils.toStringTrueFalse(_key));
} else if (DBProperties
.hasProperty(_uiValue.getField().getLabel() + "." + BooleanUtils.toStringTrueFalse(_key))) {
ret = DBProperties.getProperty(_uiValue.getField().getLabel() + "." + BooleanUtils.toStringTrueFalse(_key));
}
return ret;
} | java | {
"resource": ""
} |
q18772 | OneSelect.addObject | train | public void addObject(final Object[] _row)
throws SQLException
{
// store the ids also
this.idList.add((Long) _row[0]);
if (getFromSelect() != null) {
final int column = "id".equals(this.valueSelect.getValueType())
? this.valueSelect.getColIndexs().get(0) : 2;
this.relIdList.add((Long) _row[column - 1]);
// this means that it is a chained LinkFromSelect, but exclude
// AttributeSets
if (!getSelectParts().isEmpty() && getSelectParts().get(0) instanceof LinkFromSelect.LinkFromSelectPart
&& !(((LinkFromSelect.LinkFromSelectPart) getSelectParts().get(0)).getType()
instanceof AttributeSet)) {
this.idList.set(this.idList.size() - 1, (Long) _row[1]);
}
}
Object object = null;
final AbstractValueSelect tmpValueSelect;
if (this.valueSelect == null) {
tmpValueSelect = this.fromSelect.getMainOneSelect().getValueSelect();
} else {
tmpValueSelect = this.valueSelect;
}
if (tmpValueSelect.getParentSelectPart() != null) {
tmpValueSelect.getParentSelectPart().addObject(_row);
}
if (tmpValueSelect.getColIndexs().size() > 1) {
final Object[] objArray = new Object[tmpValueSelect.getColIndexs().size()];
int i = 0;
for (final Integer colIndex : tmpValueSelect.getColIndexs()) {
objArray[i] = _row[colIndex - 1];
i++;
}
object = objArray;
} else if (tmpValueSelect.getColIndexs().size() > 0) {
object = _row[tmpValueSelect.getColIndexs().get(0) - 1];
}
this.objectList.add(object);
} | java | {
"resource": ""
} |
q18773 | OneSelect.addFileSelectPart | train | public void addFileSelectPart()
throws EFapsException
{
final Type type;
// if a previous select exists it is based on the previous select,
// else it is based on the basic table
if (this.selectParts.size() > 0) {
type = this.selectParts.get(this.selectParts.size() - 1).getType();
} else {
type = this.query.getMainType();
}
final FileSelectPart linkto = new FileSelectPart(type);
this.selectParts.add(linkto);
} | java | {
"resource": ""
} |
q18774 | OneSelect.addGenInstSelectPart | train | public void addGenInstSelectPart()
throws EFapsException
{
final Type type;
// if a previous select exists it is based on the previous select,
// else it is based on the basic table
if (this.selectParts.size() > 0) {
type = this.selectParts.get(this.selectParts.size() - 1).getType();
} else {
type = this.query.getMainType();
}
final GenInstSelectPart linkto = new GenInstSelectPart(type);
this.selectParts.add(linkto);
} | java | {
"resource": ""
} |
q18775 | OneSelect.addAttributeSetSelectPart | train | public void addAttributeSetSelectPart(final String _attributeSet,
final String _where)
throws EFapsException
{
final Type type;
// if a previous select exists it is based on the previous select,
// else it is based on the basic table
if (this.selectParts.size() > 0) {
type = this.selectParts.get(this.selectParts.size() - 1).getType();
} else {
type = this.query.getMainType();
}
try {
final AttributeSet set = AttributeSet.find(type.getName(), _attributeSet);
final String linkFrom = set.getName() + "#" + set.getAttributeName();
this.fromSelect = new LinkFromSelect(linkFrom, getQuery().isCacheEnabled() ? getQuery().getKey() : null);
this.fromSelect.addWhere(_where);
} catch (final CacheReloadException e) {
OneSelect.LOG.error("Could not find AttributeSet for Type: {}, attribute: {}", type.getName(),
_attributeSet);
}
} | java | {
"resource": ""
} |
q18776 | OneSelect.append2SQLFrom | train | public void append2SQLFrom(final SQLSelect _select)
throws EFapsException
{
// for attributes it must be evaluated if the attribute is inside a child table
if (this.valueSelect != null && "attribute".equals(this.valueSelect.getValueType())) {
final Type type;
if (this.selectParts.size() > 0) {
type = this.selectParts.get(this.selectParts.size() - 1).getType();
} else {
type = this.query.getMainType();
}
Attribute attr = this.valueSelect.getAttribute();
if (attr == null) {
attr = type.getAttribute(((AttributeValueSelect) this.valueSelect).getAttrName());
}
// if the attr is still null that means that the type does not have this attribute, so last
// chance to find the attribute is to search in the child types
if (attr == null) {
for (final Type childType : type.getChildTypes()) {
attr = childType.getAttribute(((AttributeValueSelect) this.valueSelect).getAttrName());
if (attr != null) {
((AttributeValueSelect) this.valueSelect).setAttribute(attr);
break;
}
}
}
if (attr != null && attr.getTable() != null && !attr.getTable().equals(type.getMainTable())) {
final ChildTableSelectPart childtable = new ChildTableSelectPart(type, attr.getTable());
this.selectParts.add(childtable);
}
}
for (final ISelectPart sel : this.selectParts) {
this.tableIndex = sel.join(this, _select, this.tableIndex);
}
} | java | {
"resource": ""
} |
q18777 | OneSelect.append2SQLSelect | train | public int append2SQLSelect(final SQLSelect _select,
final int _colIndex)
throws EFapsException
{
final Type type;
if (this.selectParts.size() > 0) {
type = this.selectParts.get(this.selectParts.size() - 1).getType();
} else {
type = this.query.getMainType();
}
final int ret;
if (this.valueSelect == null) {
ret = this.fromSelect.getMainOneSelect().getValueSelect().append2SQLSelect(type, _select, this.tableIndex,
_colIndex);
} else {
ret = this.valueSelect.append2SQLSelect(type, _select, this.tableIndex, _colIndex);
}
return ret;
} | java | {
"resource": ""
} |
q18778 | OneSelect.append2SQLWhere | train | public void append2SQLWhere(final SQLSelect _select)
throws EFapsException
{
for (final ISelectPart part : this.selectParts) {
part.add2Where(this, _select);
}
} | java | {
"resource": ""
} |
q18779 | OneSelect.getObject | train | private Object getObject(final Object _object)
throws EFapsException
{
final Object ret;
// inside a fromobject the correct value must be set
if (this.fromSelect != null && _object instanceof Number) {
final List<Object> tmpList = new ArrayList<>();
final Long id = ((Number) _object).longValue();
Iterator<Long> relIter = this.relIdList.iterator();
// chained linkfroms
if (!getSelectParts().isEmpty() && getSelectParts().get(0) instanceof LinkFromSelect.LinkFromSelectPart
&& !(((LinkFromSelect.LinkFromSelectPart) getSelectParts().get(0)).getType()
instanceof AttributeSet)) {
relIter = this.idList.iterator();
} else {
relIter = this.relIdList.iterator();
}
final Iterator<Object> objIter = this.objectList.iterator();
while (relIter.hasNext()) {
final Long rel = relIter.next();
final Object obj = objIter.next();
if (rel.equals(id)) {
tmpList.add(obj);
}
}
if (this.valueSelect == null) {
final List<Object> retTmp = new ArrayList<>();
for (final Object obj : tmpList) {
retTmp.add(this.fromSelect.getMainOneSelect().getObject(obj));
}
ret = retTmp.size() > 0 ? retTmp.size() > 1 ? retTmp : retTmp.get(0) : null;
} else {
ret = this.valueSelect.getValue(tmpList);
}
} else {
ret = this.getObject();
}
return ret;
} | java | {
"resource": ""
} |
q18780 | OneSelect.getObject | train | public Object getObject()
throws EFapsException
{
Object ret = null;
if (this.valueSelect == null) {
// if the fromSelect has data
if (this.fromSelect.hasResult()) {
// and there are more than one id the current object must not be null
if (this.idList.size() > 1 && this.currentObject != null) {
ret = this.fromSelect.getMainOneSelect().getObject(this.currentObject);
// or if there is only one id the first objectvalue must not be null
} else if (this.idList.size() == 1 && this.objectList.get(0) != null) {
ret = this.fromSelect.getMainOneSelect().getObject(this.currentObject);
}
}
} else {
// if the currentObject is not null it means that the values are
// retrieved by iteration through the object list
if (this.currentId != null) {
ret = this.valueSelect.getValue(this.currentObject);
} else {
ret = this.valueSelect.getValue(this.objectList);
}
}
return ret;
} | java | {
"resource": ""
} |
q18781 | OneSelect.getInstances | train | @SuppressWarnings("unchecked")
public List<Instance> getInstances()
throws EFapsException
{
final List<Instance> ret = new ArrayList<>();
// no value select means, that the from select must be asked
if (this.valueSelect == null) {
ret.addAll(this.fromSelect.getMainOneSelect().getInstances());
} else {
// if an oid select was given the oid is evaluated
if ("oid".equals(this.valueSelect.getValueType())) {
for (final Object object : this.objectList) {
final Instance inst = Instance.get((String) this.valueSelect.getValue(object));
if (inst.isValid()) {
ret.add(inst);
}
}
} else {
final List<Long> idTmp;
if (this.valueSelect.getParentSelectPart() != null
&& this.valueSelect.getParentSelectPart() instanceof LinkToSelectPart) {
idTmp = (List<Long>) this.valueSelect.getParentSelectPart().getObject();
} else {
idTmp = this.idList;
}
for (final Long id : idTmp) {
if (id != null) {
ret.add(Instance.get(this.valueSelect.getAttribute().getParent(), String.valueOf(id)));
}
}
}
}
return ret;
} | java | {
"resource": ""
} |
q18782 | OneSelect.sortByInstanceList | train | public void sortByInstanceList(final List<Instance> _targetList,
final Map<Instance, Integer> _currentList)
{
final List<Long> idListNew = new ArrayList<>();
final List<Object> objectListNew = new ArrayList<>();
for (final Instance instance : _targetList) {
if (_currentList.containsKey(instance)) {
final Integer i = _currentList.get(instance);
idListNew.add(this.idList.get(i));
objectListNew.add(this.objectList.get(i));
}
}
this.idList.clear();
this.idList.addAll(idListNew);
this.objectList.clear();
this.objectList.addAll(objectListNew);
} | java | {
"resource": ""
} |
q18783 | TedDriver.createTask | train | public Long createTask(String taskName, String data) {
return tedDriverImpl.createTask(taskName, data, null, null, null);
} | java | {
"resource": ""
} |
q18784 | TedDriver.createBatch | train | public Long createBatch(String batchTaskName, String data, String key1, String key2, List<TedTask> tedTasks) {
return tedDriverImpl.createBatch(batchTaskName, data, key1, key2, tedTasks);
} | java | {
"resource": ""
} |
q18785 | TedDriver.createEvent | train | public Long createEvent(String taskName, String queueId, String data, String key2) {
return tedDriverImpl.createEvent(taskName, queueId, data, key2);
} | java | {
"resource": ""
} |
q18786 | TedDriver.createEventAndTryExecute | train | public Long createEventAndTryExecute(String taskName, String queueId, String data, String key2) {
return tedDriverImpl.createEventAndTryExecute(taskName, queueId, data, key2);
} | java | {
"resource": ""
} |
q18787 | TedDriver.sendNotification | train | public Long sendNotification(String taskName, String data) {
return tedDriverImpl.sendNotification(taskName, data);
} | java | {
"resource": ""
} |
q18788 | Arc.set | train | public void set(double x, double y, double r, double radStart, double radEnd) {
this.x = x;
this.y = y;
this.w = r * 2;
this.h = r * 2;
this.radStart = radStart;
this.radEnd = radEnd;
} | java | {
"resource": ""
} |
q18789 | Arc.setCenterColor | train | public void setCenterColor(ColorSet colorSet) {
if (this.centerColor == null) {
this.centerColor = new RGBColor(0.0, 0.0, 0.0);
}
setGradation(true);
this.centerColor = RGBColor.color(colorSet);
} | java | {
"resource": ""
} |
q18790 | Arc.setEdgeColor | train | public void setEdgeColor(Color color) {
if (edgeColor == null) edgeColor = new RGBColor(0.0, 0.0, 0.0);
setGradation(true);
this.edgeColor = color;
} | java | {
"resource": ""
} |
q18791 | Arc.setEdgeColor | train | public void setEdgeColor(ColorSet colorSet) {
if (edgeColor == null) edgeColor = new RGBColor(0.0, 0.0, 0.0);
setGradation(true);
this.edgeColor = RGBColor.color(colorSet);
} | java | {
"resource": ""
} |
q18792 | Searcher.addSubDimension | train | private void addSubDimension(final Facets _facets,
final DimValue _dimValue,
final String _dim,
final String _path)
throws IOException
{
final FacetResult result = _facets.getTopChildren(1000, _dim, _path);
if (result != null) {
LOG.debug("FacetResult {}.", result);
for (final LabelAndValue labelValue : result.labelValues) {
final DimValue dimValue = new DimValue().setLabel(labelValue.label)
.setValue(labelValue.value.intValue());
dimValue.setPath(ArrayUtils.addAll(_dimValue.getPath(), result.path));
_dimValue.getChildren().add(dimValue);
addSubDimension(_facets, dimValue, _dim, _path + "/" + labelValue.label);
}
}
} | java | {
"resource": ""
} |
q18793 | Searcher.checkAccess | train | private void checkAccess()
throws EFapsException
{
// check the access for the given instances
final Map<Instance, Boolean> accessmap = new HashMap<Instance, Boolean>();
for (final Entry<Type, List<Instance>> entry : this.typeMapping.entrySet()) {
accessmap.putAll(entry.getKey().checkAccess(entry.getValue(), AccessTypeEnums.SHOW.getAccessType()));
}
this.elements.entrySet().removeIf(entry -> accessmap.size() > 0 && (!accessmap.containsKey(entry.getKey())
|| !accessmap.get(entry.getKey())));
} | java | {
"resource": ""
} |
q18794 | PoolMemoryMetricsCollector.recordMetricsForPool | train | protected void recordMetricsForPool(final MemoryPoolMXBean pool, final Metrics metrics) {
final MemoryUsage usage = pool.getUsage();
metrics.setGauge(
String.join(
"/",
ROOT_NAMESPACE,
memoryTypeSegment(pool.getType()),
MetricsUtil.convertToSnakeCase(pool.getName()),
MEMORY_USED),
usage.getUsed(),
Units.BYTE
);
final long memoryMax = usage.getMax();
if (memoryMax != -1) {
metrics.setGauge(
String.join(
"/",
ROOT_NAMESPACE,
memoryTypeSegment(pool.getType()),
MetricsUtil.convertToSnakeCase(pool.getName()),
MEMORY_MAX),
memoryMax,
Units.BYTE
);
}
} | java | {
"resource": ""
} |
q18795 | Curve.setNode | train | public void setNode(int number, double x, double y) {
if (number <= 0) number = 0;
if (number >= 3) number = 3;
this.points[number * 3] = (float)x;
this.points[number * 3 + 1] = (float)y;
this.points[number * 3 + 2] = 0;
set();
} | java | {
"resource": ""
} |
q18796 | Curve.setNode | train | public void setNode(int number, Vector3D v) {
if (number <= 0) {
number = 0;
} else if (3 <= number) {
number = 3;
}
this.points[number * 3] = (float)v.getX();
this.points[number * 3 + 1] = (float)v.getY();
this.points[number * 3 + 2] = (float)v.getZ();
set();
} | java | {
"resource": ""
} |
q18797 | Curve.curvePoint | train | public double curvePoint(XYZ vec, float t) {
double tmp = 0;
switch (vec) {
case X:
tmp = catmullRom(points[0], points[3], points[6], points[9], t);
break;
case Y:
tmp = catmullRom(points[1], points[4], points[7], points[10], t);
break;
default:
break;
}
return tmp;
} | java | {
"resource": ""
} |
q18798 | AbstractPrintQuery.getAttribute | train | @SuppressWarnings("unchecked")
public <T> T getAttribute(final Attribute _attribute)
throws EFapsException
{
return (T) getAttribute(_attribute.getName());
} | java | {
"resource": ""
} |
q18799 | AbstractPrintQuery.addAttributeSet | train | public AbstractPrintQuery addAttributeSet(final String _setName)
throws EFapsException
{
final Type type = getMainType();
if (type != null) {
final AttributeSet set = AttributeSet.find(type.getName(), _setName);
addAttributeSet(set);
}
return this;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.