_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18800 | AbstractPrintQuery.addAttributeSet | train | public AbstractPrintQuery addAttributeSet(final AttributeSet _set)
throws EFapsException
{
final String key = "linkfrom[" + _set.getName() + "#" + _set.getAttributeName() + "]";
final OneSelect oneselect = new OneSelect(this, key);
this.allSelects.add(oneselect);
this.attr2OneSelect.put(_set.getAttributeName(), oneselect);
oneselect.analyzeSelectStmt();
for (final String setAttrName : _set.getSetAttributes()) {
if (!setAttrName.equals(_set.getAttributeName())) {
oneselect.getFromSelect().addOneSelect(new OneSelect(this, _set.getAttribute(setAttrName)));
}
}
oneselect.getFromSelect().getMainOneSelect().setAttribute(_set.getAttribute(_set.getAttributeName()));
return this;
} | java | {
"resource": ""
} |
q18801 | AbstractPrintQuery.getAttributeSet | train | @SuppressWarnings("unchecked")
public <T> T getAttributeSet(final String _setName)
throws EFapsException
{
final OneSelect oneselect = this.attr2OneSelect.get(_setName);
Map<String, Object> ret = null;
if (oneselect == null || oneselect.getFromSelect() == null) {
AbstractPrintQuery.LOG.error("Could not get an AttributeSet for the name: '{}' in PrintQuery '{]'",
_setName, this);
} else if (oneselect.getFromSelect().hasResult()) {
ret = new HashMap<>();
// in an attributset the first one is fake
boolean first = true;
for (final OneSelect onsel : oneselect.getFromSelect().getAllSelects()) {
if (first) {
first = false;
} else {
final ArrayList<Object> list = new ArrayList<>();
final Object object = onsel.getObject();
if (object instanceof List<?>) {
list.addAll((List<?>) object);
} else {
list.add(object);
}
ret.put(onsel.getAttribute().getName(), list);
}
}
}
return (T) ret;
} | java | {
"resource": ""
} |
q18802 | AbstractPrintQuery.getAttribute4Select | train | public Attribute getAttribute4Select(final String _selectStmt)
{
final OneSelect oneselect = this.selectStmt2OneSelect.get(_selectStmt);
return oneselect == null ? null : oneselect.getAttribute();
} | java | {
"resource": ""
} |
q18803 | AbstractPrintQuery.getInstances4Select | train | public List<Instance> getInstances4Select(final String _selectStmt)
throws EFapsException
{
final OneSelect oneselect = this.selectStmt2OneSelect.get(_selectStmt);
return oneselect == null ? new ArrayList<>() : oneselect.getInstances();
} | java | {
"resource": ""
} |
q18804 | AbstractPrintQuery.isList4Select | train | public boolean isList4Select(final String _selectStmt)
throws EFapsException
{
final OneSelect oneselect = this.selectStmt2OneSelect.get(_selectStmt);
return oneselect == null ? false : oneselect.isMultiple();
} | java | {
"resource": ""
} |
q18805 | AbstractPrintQuery.getNewTableIndex | train | public Integer getNewTableIndex(final String _tableName,
final String _column,
final Integer _relIndex,
final Long _clazzId)
{
this.tableIndex++;
this.sqlTable2Index.put(_relIndex + "__" + _tableName + "__" + _column
+ (_clazzId == null ? "" : "__" + _clazzId), this.tableIndex);
return this.tableIndex;
} | java | {
"resource": ""
} |
q18806 | AppModuleGenerator.generate | train | @Override
public void generate(final Module module, final Element parent) {
final AppModule m = (AppModule) module;
if (m.getDraft() != null) {
final String draft = m.getDraft().booleanValue() ? "yes" : "no";
final Element control = new Element("control", APP_NS);
control.addContent(generateSimpleElement("draft", draft));
parent.addContent(control);
}
if (m.getEdited() != null) {
final Element edited = new Element("edited", APP_NS);
// Inclulde millis in date/time
final SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
dateFormater.setTimeZone(TimeZone.getTimeZone("GMT"));
edited.addContent(dateFormater.format(m.getEdited()));
parent.addContent(edited);
}
} | java | {
"resource": ""
} |
q18807 | Applet.setCursor | train | public void setCursor(CursorMode cursorMode) {
Cursor c = CursorMode.getAWTCursor(cursorMode);
if (c.getType() == panel.getCursor().getType()) return;
panel.setCursor(c);
} | java | {
"resource": ""
} |
q18808 | Key.get4Instance | train | public static Key get4Instance(final Instance _instance)
throws EFapsException
{
Key.LOG.debug("Retrieving Key for {}", _instance);
final Key ret = new Key();
ret.setPersonId(Context.getThreadContext().getPersonId());
final Type type = _instance.getType();
ret.setTypeId(type.getId());
if (type.isCompanyDependent()) {
ret.setCompanyId(Context.getThreadContext().getCompany().getId());
}
Key.LOG.debug("Retrieved Key {}", ret);
return ret;
} | java | {
"resource": ""
} |
q18809 | RestRequest.execute | train | public T execute() throws ApiException, IOException {
return client.executeRequest(this.builder, expectedCode, responseClass, needAuth);
} | java | {
"resource": ""
} |
q18810 | RestRequest.executeAsync | train | public Future<T> executeAsync(final RestCallback<T> handler) {
return client.submit(new Callable<T>() {
@Override
public T call() throws Exception {
try {
final T result = execute();
handler.completed(result, RestRequest.this);
return result;
} catch (Exception e) {
handler.failed(e, RestRequest.this);
throw e;
}
}
});
} | java | {
"resource": ""
} |
q18811 | RestRequest.executeAsync | train | public Future<T> executeAsync() {
return client.submit(new Callable<T>() {
@Override
public T call() throws Exception {
return execute();
}
});
} | java | {
"resource": ""
} |
q18812 | Image.getTypeIcon | train | public static Image getTypeIcon(final Type _type)
throws EFapsException
{
Image ret = null;
if (_type != null) {
ret = _type.getTypeIcon();
}
return ret;
} | java | {
"resource": ""
} |
q18813 | Update.addAlwaysUpdateAttributes | train | protected void addAlwaysUpdateAttributes()
throws EFapsException
{
final Iterator<?> iter = getInstance().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.isAlwaysUpdate()) {
addInternal(attr, false, (Object[]) null);
}
}
} | java | {
"resource": ""
} |
q18814 | Update.executeWithoutTrigger | train | public void executeWithoutTrigger()
throws EFapsException
{
if (Update.STATUSOK.getStati().isEmpty()) {
final Context context = Context.getThreadContext();
ConnectionResource con = null;
try {
con = context.getConnectionResource();
for (final Entry<SQLTable, List<Value>> entry : this.table2values.entrySet()) {
final SQLUpdate update = Context.getDbType().newUpdate(entry.getKey().getSqlTable(),
entry.getKey().getSqlColId(),
getInstance().getId());
// iterate in reverse order and only execute the ones that are not added yet, permitting
// to overwrite the value for attributes by adding them later
final ReverseListIterator<Value> iterator = new ReverseListIterator<>(entry.getValue());
final Set<String> added = new HashSet<>();
while (iterator.hasNext()) {
final Value value = iterator.next();
final String colKey = value.getAttribute().getSqlColNames().toString();
if (!added.contains(colKey)) {
value.getAttribute().prepareDBUpdate(update, value.getValues());
added.add(colKey);
}
}
final Set<String> updatedColumns = update.execute(con);
final Iterator<Entry<Attribute, Value>> attrIter = this.trigRelevantAttr2values.entrySet()
.iterator();
while (attrIter.hasNext()) {
final Entry<Attribute, Value> trigRelEntry = attrIter.next();
if (trigRelEntry.getKey().getTable().equals(entry.getKey())) {
boolean updated = false;
for (final String colName : trigRelEntry.getKey().getSqlColNames()) {
if (updatedColumns.contains(colName)) {
updated = true;
break;
}
}
if (!updated) {
attrIter.remove();
}
}
}
}
AccessCache.registerUpdate(getInstance());
Queue.registerUpdate(getInstance());
} catch (final SQLException e) {
Update.LOG.error("Update of '" + this.instance + "' not possible", e);
throw new EFapsException(getClass(), "executeWithoutTrigger.SQLException", e, this.instance);
}
} else {
throw new EFapsException(getClass(), "executeWithout.StatusInvalid", Update.STATUSOK.getStati());
}
} | java | {
"resource": ""
} |
q18815 | IndexUploader.updateSearchFunctionIfNecessary | train | public boolean updateSearchFunctionIfNecessary(CouchDbConnector db, String viewName, String searchFunction,
String javascriptIndexFunctionBody) {
boolean updatePerformed = false;
String designDocName = viewName.startsWith(DesignDocument.ID_PREFIX)
? viewName : (DesignDocument.ID_PREFIX + viewName);
Checksum chk = new CRC32();
byte[] bytes = javascriptIndexFunctionBody.getBytes();
chk.update(bytes, 0, bytes.length);
long actualChk = chk.getValue();
if (!db.contains(designDocName)) {
// it doesn't exist, let's put one in
DesignDocument doc = new DesignDocument(designDocName);
db.create(doc);
updateSearchFunction(db, doc, searchFunction, javascriptIndexFunctionBody, actualChk);
updatePerformed = true;
} else {
// make sure it's up to date
DesignDocument doc = db.get(DesignDocument.class, designDocName);
Number docChk = (Number) doc.getAnonymous().get(getChecksumFieldName(searchFunction));
if (docChk == null || !(docChk.longValue() == actualChk)) {
log.info("Updating the index function");
updateSearchFunction(db, doc, searchFunction, javascriptIndexFunctionBody, actualChk);
updatePerformed = true;
}
}
return updatePerformed;
} | java | {
"resource": ""
} |
q18816 | IndexUploader.updateSearchFunction | train | private void updateSearchFunction(CouchDbConnector db, DesignDocument doc, String searchFunctionName,
String javascript, long jsChecksum) {
// get the 'fulltext' object from the design document, this is what couchdb-lucene uses to index couch
Map<String, Map<String, String>> fullText = (Map<String, Map<String, String>>) doc.getAnonymous().get("fulltext");
if (fullText == null) {
fullText = new HashMap<String, Map<String, String>>();
doc.setAnonymous("fulltext", fullText);
}
// now grab the search function that the user wants to use to index couch
Map<String, String> searchObject = fullText.get(searchFunctionName);
if (searchObject == null) {
searchObject = new HashMap<String, String>();
fullText.put(searchFunctionName, searchObject);
}
// now set the contents of the index function
searchObject.put("index", javascript);
// now set the checksum, so that we can make sure that we only update it when we need to
doc.setAnonymous(getChecksumFieldName(searchFunctionName), jsChecksum);
// save out the document
db.update(doc);
} | java | {
"resource": ""
} |
q18817 | DataConnection.connect | train | public void connect() throws Exception {
logger.debug("[connect] initializing new connection");
synchronized (webSocketHandler.getNotifyConnectionObject()) {
webSocketConnectionManager.start();
try {
webSocketHandler.getNotifyConnectionObject().wait(TimeUnit.SECONDS.toMillis(WEBSOCKET_TIMEOUT));
}
catch (InterruptedException e) {
throw new Exception("websocket connection not open");
}
if (!isConnected()) {
throw new Exception("websocket connection timeout (uri = " + uriTemplate + ")");
}
}
} | java | {
"resource": ""
} |
q18818 | DataConnection.isUsable | train | public boolean isUsable() {
return isConnected() && TimeUnit.MILLISECONDS.toMinutes(new Date().getTime() - lastUsage.getTime()) <= MAXIMUM_AGE_IN_MINUTES;
} | java | {
"resource": ""
} |
q18819 | DataStore.add | train | public void add(long timestamp, String column, Object value) {
if (!(value instanceof Long) && !(value instanceof Integer) && !(value instanceof Double) &&
!(value instanceof Float) && !(value instanceof Boolean) &&
!(value instanceof String)) {
throw new IllegalArgumentException(
"value must be of type: Long, Integer, Double, Float, Boolean, or String");
}
Map<String, Object> temp = new HashMap<String, Object>();
temp.put(column, value);
add(timestamp, temp);
} | java | {
"resource": ""
} |
q18820 | DataStore.add | train | public void add(String column, Object value) {
add(System.currentTimeMillis(), column, value);
} | java | {
"resource": ""
} |
q18821 | DataStore.add | train | public void add(String[] columns, Object[] values) {
add(System.currentTimeMillis(), columns, values);
} | java | {
"resource": ""
} |
q18822 | DataStore.add | train | public void add(long timestamp, Map<String, Object> data) {
for (String k : data.keySet()) {
if (!columns.contains(k)) {
throw new UnknownFieldException(k);
}
}
Map<String, Object> curr = this.rows.get(timestamp);
if (curr == null) {
this.rows.put(timestamp, new HashMap<String, Object>(data));
} else {
curr.putAll(data);
}
} | java | {
"resource": ""
} |
q18823 | DataStore.merge | train | public void merge(DataStore other) {
if (!this.hasSameColumns(other)) {
throw new IllegalArgumentException("DataStore must have the same columns to merge");
}
this.rows.putAll(other.rows);
} | java | {
"resource": ""
} |
q18824 | DataStore.getRows | train | public TreeMap<Long, Map<String, Object>> getRows() {
return new TreeMap<Long, Map<String, Object>>(this.rows);
} | java | {
"resource": ""
} |
q18825 | DataStore.hasColumns | train | public boolean hasColumns(Collection<String> columns) {
return columns != null && this.columns.equals(new TreeSet<String>(columns));
} | java | {
"resource": ""
} |
q18826 | DataStore.fromJson | train | public static DataStore fromJson(final JSONObject json) throws ParseException {
DataStore ret;
JSONArray jsonCols = json.getJSONArray("fields");
if (!"time".equals(jsonCols.get(0))) {
throw new JSONException("time must be the first item in 'fields'");
}
Set<String> cols = new HashSet<String>();
for (int i = 1; i < jsonCols.length(); i++) {
cols.add(jsonCols.getString(i));
}
ret = new DataStore(cols);
JSONArray jsonData = json.getJSONArray("data");
for (int i = 0; i < jsonData.length(); i++) {
JSONArray row = jsonData.getJSONArray(i);
Long ts = row.getLong(0);
Map<String, Object> vals = new HashMap<String, Object>();
for (int j = 1; j < row.length(); j++) {
vals.put(jsonCols.getString(j), row.get(j));
}
ret.rows.put(ts, vals);
}
return ret;
} | java | {
"resource": ""
} |
q18827 | DataStore.toJson | train | public JSONObject toJson() {
JSONObject ret = new JSONObject();
JSONArray columns = new JSONArray(Arrays.asList(new String[]{"time"}));
for (String f : this.columns) {
columns.put(f);
}
ret.put(KEY_COLUMNS, columns);
JSONArray data = new JSONArray();
ret.put(KEY_ROWS, data);
for (Long ts : rows.keySet()) {
JSONArray row = new JSONArray();
row.put(ts);
Map<String, Object> temp = rows.get(ts);
for (String f : this.columns) {
Object val = temp.get(f);
row.put(val != null ? val : JSONObject.NULL);
}
data.put(row);
}
return ret;
} | java | {
"resource": ""
} |
q18828 | AbstractCollection.add | train | public void add(final Field _field)
{
this.fields.put(_field.getId(), _field);
this.fieldName2Field.put(_field.getName(), _field);
if (_field.getReference() != null && _field.getReference().length() > 0) {
final String ref = _field.getReference();
int index;
int end = 0;
while ((index = ref.indexOf("$<", end)) > 0) {
index += 2;
end = ref.indexOf(">", index);
addFieldExpr(ref.substring(index, end));
}
}
_field.setCollectionUUID(getUUID());
} | java | {
"resource": ""
} |
q18829 | AbstractCollection.addFieldExpr | train | protected int addFieldExpr(final String _expr)
{
int ret = -1;
if (getAllFieldExpr().containsKey(_expr)) {
ret = getFieldExprIndex(_expr);
} else {
getAllFieldExpr().put(_expr, Integer.valueOf(getSelIndexLen()));
if (getSelect() == null) {
setSelect(_expr);
} else {
setSelect(getSelect() + "," + _expr);
}
ret = getSelIndexLen();
this.selIndexLen++;
}
return ret;
} | java | {
"resource": ""
} |
q18830 | AbstractCollection.readFromDB4Fields | train | private void readFromDB4Fields()
throws CacheReloadException
{
try {
final QueryBuilder queryBldr = new QueryBuilder(CIAdminUserInterface.Field);
queryBldr.addWhereAttrEqValue(CIAdminUserInterface.Field.Collection, getId());
final MultiPrintQuery multi = queryBldr.getPrint();
multi.addAttribute(CIAdminUserInterface.Field.Type,
CIAdminUserInterface.Field.Name);
multi.executeWithoutAccessCheck();
while (multi.next()) {
final long id = multi.getCurrentInstance().getId();
final String name = multi.<String>getAttribute(CIAdminUserInterface.Field.Name);
final Type type = multi.<Type>getAttribute(CIAdminUserInterface.Field.Type);
final Field field;
if (type.equals(CIAdminUserInterface.FieldCommand.getType())) {
field = new FieldCommand(id, null, name);
} else if (type.equals(CIAdminUserInterface.FieldHeading.getType())) {
field = new FieldHeading(id, null, name);
} else if (type.equals(CIAdminUserInterface.FieldTable.getType())) {
field = new FieldTable(id, null, name);
} else if (type.equals(CIAdminUserInterface.FieldGroup.getType())) {
field = new FieldGroup(id, null, name);
} else if (type.equals(CIAdminUserInterface.FieldSet.getType())) {
field = new FieldSet(id, null, name);
} else if (type.equals(CIAdminUserInterface.FieldClassification.getType())) {
field = new FieldClassification(id, null, name);
} else if (type.equals(CIAdminUserInterface.FieldPicker.getType())) {
field = new FieldPicker(id, null, name);
} else {
field = new Field(id, null, name);
}
field.readFromDB();
add(field);
}
} catch (final EFapsException e) {
throw new CacheReloadException("could not read fields for '" + getName() + "'", e);
}
} | java | {
"resource": ""
} |
q18831 | RestContext.setCompany | train | @Path("setCompany")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN })
@SuppressWarnings("checkstyle:illegalcatch")
public Response setCompany(@QueryParam("company") final String _companyStr)
{
try {
final Company company;
if (UUIDUtil.isUUID(_companyStr)) {
company = Company.get(UUID.fromString(_companyStr));
} else if (StringUtils.isNumeric(_companyStr)) {
company = Company.get(Long.parseLong(_companyStr));
} else {
company = Company.get(_companyStr);
}
if (company != null && company.hasChildPerson(Context.getThreadContext().getPerson())) {
Context.getThreadContext().setUserAttribute(Context.CURRENTCOMPANY, String.valueOf(company.getId()));
Context.getThreadContext().getUserAttributes().storeInDb();
Context.getThreadContext().setCompany(company);
}
} catch (final NumberFormatException | EFapsException e) {
RestContext.LOG.error("Catched error", e);
}
return confirm();
} | java | {
"resource": ""
} |
q18832 | Database.onServerAvailable | train | public synchronized void onServerAvailable(final String id, final String role) {
logger.debug("[onServerAvailable] id = {}, role = {}", id, role);
Server server = getServerById(id);
boolean isMaster = role.equals("master");
boolean isSlave = role.equals("slave");
if (server == null) {
return;
}
if (server.isAvailable()) {
if (server.isMaster() && isMaster) return;
if (!server.isMaster() && isSlave) return;
}
if (isMaster || isSlave) {
server.setAvailable(true);
try {
server.connect();
}
catch (Exception e) {
logger.error("[onServerAvailable]", e);
}
}
server.setAvailable(true);
if (isMaster) {
setWriteServer(server);
}
refreshServers();
} | java | {
"resource": ""
} |
q18833 | Database.onServerUnavailable | train | public synchronized void onServerUnavailable(final String id) {
logger.debug("[onServerUnavailable] id = {}", id);
Server server = getServerById(id);
if (server != null) {
server.setAvailable(false);
refreshServers();
}
} | java | {
"resource": ""
} |
q18834 | Database.onServerReconnected | train | public synchronized void onServerReconnected(final String id, final String uri) {
logger.debug("[onServerReconnected] id = {}, uri = {}", id, uri);
if (id.length() == 0) {
Server server = getServerByUri(uri);
server.register();
server.setAvailable(true);
}
refreshServers();
} | java | {
"resource": ""
} |
q18835 | Database.getReadServer | train | protected Server getReadServer() {
Server[] servers = readServers;
return servers[readSequence.incrementAndGet(servers.length)];
} | java | {
"resource": ""
} |
q18836 | AdjacencyList.calculateInDegrees | train | @Override
public int[] calculateInDegrees() {
final int[] in_degrees = new int[size()];
for(int i = 0; i < size(); ++i) {
final IAdjacencyListPair<TVertex> p = pairAt(i);
final TVertex d = p.getVertex();
for(int j = 0; j < size(); ++j) {
for(IVertex dep : pairAt(j).getOutNeighbors()) {
if (d.equals(dep))
++in_degrees[i];
}
}
}
return in_degrees;
} | java | {
"resource": ""
} |
q18837 | WebSocketHandler.afterConnectionEstablished | train | @Override
public void afterConnectionEstablished(final WebSocketSession webSocketSession) {
logger.debug("[afterConnectionEstablished] id = {}", webSocketSession.getId());
this.session = webSocketSession;
synchronized (notifyConnectionObject) {
notifyConnectionObject.notifyAll();
}
} | java | {
"resource": ""
} |
q18838 | WebSocketHandler.afterConnectionClosed | train | @Override
public void afterConnectionClosed(final WebSocketSession webSocketSession, final CloseStatus status) {
logger.debug("[afterConnectionClosed] id = ", webSocketSession.getId());
this.session = null;
if (connectionListener != null) {
connectionListener.onConnectionClosed();
}
} | java | {
"resource": ""
} |
q18839 | WebSocketHandler.handleTransportError | train | @Override
public void handleTransportError(final WebSocketSession webSocketSession, final Throwable exception) throws Exception {
if (exception != null) {
logger.error("[handleTransportError]", exception);
}
} | java | {
"resource": ""
} |
q18840 | WebSocketHandler.sendMessage | train | public void sendMessage(final String message) {
try {
session.sendMessage(new TextMessage(message));
}
catch (IOException e) {
logger.error("[sendTextMessage]", e);
}
} | java | {
"resource": ""
} |
q18841 | WebSocketHandler.sendMessage | train | public void sendMessage(final byte[] message) {
try {
session.sendMessage(new BinaryMessage(message));
}
catch (IOException e) {
logger.error("[sendBinaryMessage]", e);
}
} | java | {
"resource": ""
} |
q18842 | Context.getStoreResource | train | public Resource getStoreResource(final Instance _instance,
final Resource.StoreEvent _event)
throws EFapsException
{
Resource storeRsrc = null;
final Store store = Store.get(_instance.getType().getStoreId());
storeRsrc = store.getResource(_instance);
storeRsrc.open(_event);
this.storeStore.add(storeRsrc);
return storeRsrc;
} | java | {
"resource": ""
} |
q18843 | Context.getParameter | train | public String getParameter(final String _key)
{
String value = null;
if (this.parameters != null) {
final String[] values = this.parameters.get(_key);
if (values != null && values.length > 0) {
value = values[0];
}
}
return value;
} | java | {
"resource": ""
} |
q18844 | Context.setRequestAttribute | train | public Object setRequestAttribute(final String _key,
final Object _value)
{
return this.requestAttributes.put(_key, _value);
} | java | {
"resource": ""
} |
q18845 | Context.setSessionAttribute | train | public Object setSessionAttribute(final String _key,
final Object _value)
{
return this.sessionAttributes.put(_key, _value);
} | java | {
"resource": ""
} |
q18846 | Context.getUserAttributes | train | public UserAttributesSet getUserAttributes()
throws EFapsException
{
if (containsSessionAttribute(UserAttributesSet.CONTEXTMAPKEY)) {
return (UserAttributesSet) getSessionAttribute(UserAttributesSet.CONTEXTMAPKEY);
} else {
throw new EFapsException(Context.class, "getUserAttributes.NoSessionAttribute");
}
} | java | {
"resource": ""
} |
q18847 | Context.setCompany | train | public void setCompany(final Company _company)
throws CacheReloadException
{
if (_company == null) {
this.companyId = null;
} else {
this.companyId = _company.getId();
}
} | java | {
"resource": ""
} |
q18848 | Context.getThreadContext | train | public static Context getThreadContext()
throws EFapsException
{
Context context = Context.THREADCONTEXT.get();
if (context == null) {
context = Context.INHERITTHREADCONTEXT.get();
}
if (context == null) {
throw new EFapsException(Context.class, "getThreadContext.NoContext4ThreadDefined");
}
return context;
} | java | {
"resource": ""
} |
q18849 | Context.save | train | public static void save()
throws EFapsException
{
try {
Context.TRANSMANAG.commit();
Context.TRANSMANAG.begin();
final Context context = Context.getThreadContext();
context.connectionResource = null;
context.setTransaction(Context.TRANSMANAG.getTransaction());
} catch (final SecurityException e) {
throw new EFapsException(Context.class, "save.SecurityException", e);
} catch (final IllegalStateException e) {
throw new EFapsException(Context.class, "save.IllegalStateException", e);
} catch (final RollbackException e) {
throw new EFapsException(Context.class, "save.RollbackException", e);
} catch (final HeuristicMixedException e) {
throw new EFapsException(Context.class, "save.HeuristicMixedException", e);
} catch (final HeuristicRollbackException e) {
throw new EFapsException(Context.class, "save.HeuristicRollbackException", e);
} catch (final SystemException e) {
throw new EFapsException(Context.class, "save.SystemException", e);
} catch (final NotSupportedException e) {
throw new EFapsException(Context.class, "save.NotSupportedException", e);
}
} | java | {
"resource": ""
} |
q18850 | Context.isTMActive | train | public static boolean isTMActive()
throws EFapsException
{
try {
return Context.TRANSMANAG.getStatus() == Status.STATUS_ACTIVE;
} catch (final SystemException e) {
throw new EFapsException(Context.class, "isTMActive.SystemException", e);
}
} | java | {
"resource": ""
} |
q18851 | Context.isTMNoTransaction | train | public static boolean isTMNoTransaction()
throws EFapsException
{
try {
return Context.TRANSMANAG.getStatus() == Status.STATUS_NO_TRANSACTION;
} catch (final SystemException e) {
throw new EFapsException(Context.class, "isTMNoTransaction.SystemException", e);
}
} | java | {
"resource": ""
} |
q18852 | Context.isTMMarkedRollback | train | public static boolean isTMMarkedRollback()
throws EFapsException
{
try {
return Context.TRANSMANAG.getStatus() == Status.STATUS_MARKED_ROLLBACK;
} catch (final SystemException e) {
throw new EFapsException(Context.class, "isTMMarkedRollback.SystemException", e);
}
} | java | {
"resource": ""
} |
q18853 | Context.reset | train | public static void reset()
throws StartupException
{
try {
final InitialContext initCtx = new InitialContext();
final javax.naming.Context envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");
Context.DBTYPE = (AbstractDatabase<?>) envCtx.lookup(INamingBinds.RESOURCE_DBTYPE);
Context.DATASOURCE = (DataSource) envCtx.lookup(INamingBinds.RESOURCE_DATASOURCE);
Context.TRANSMANAG = (TransactionManager) envCtx.lookup(INamingBinds.RESOURCE_TRANSMANAG);
try {
Context.TRANSMANAGTIMEOUT = 0;
final Map<?, ?> props = (Map<?, ?>) envCtx.lookup(INamingBinds.RESOURCE_CONFIGPROPERTIES);
if (props != null) {
final String transactionTimeoutString = (String) props.get(IeFapsProperties.TRANSACTIONTIMEOUT);
if (transactionTimeoutString != null) {
Context.TRANSMANAGTIMEOUT = Integer.parseInt(transactionTimeoutString);
}
}
} catch (final NamingException e) {
// this is actual no error, so nothing is presented
Context.TRANSMANAGTIMEOUT = 0;
}
} catch (final NamingException e) {
throw new StartupException("eFaps context could not be initialized", e);
}
} | java | {
"resource": ""
} |
q18854 | LinkFromSelect.execute | train | public boolean execute(final OneSelect _onesel)
throws EFapsException
{
this.hasResult = executeOneCompleteStmt(createSQLStatement(_onesel), getAllSelects());
if (this.hasResult) {
for (final OneSelect onesel : getAllSelects()) {
if (onesel.getFromSelect() != null && !onesel.getFromSelect().equals(this)) {
onesel.getFromSelect().execute(onesel);
}
}
}
return this.hasResult;
} | java | {
"resource": ""
} |
q18855 | LinkFromSelect.getAllChildTypes | train | private List<Type> getAllChildTypes(final Type _parent)
throws CacheReloadException
{
final List<Type> ret = new ArrayList<>();
for (final Type child : _parent.getChildTypes()) {
ret.addAll(getAllChildTypes(child));
ret.add(child);
}
return ret;
} | java | {
"resource": ""
} |
q18856 | JasperUtil.getJasperDesign | train | public static JasperDesign getJasperDesign(final Instance _instance)
throws EFapsException
{
final Checkout checkout = new Checkout(_instance);
final InputStream source = checkout.execute();
JasperDesign jasperDesign = null;
try {
JasperUtil.LOG.debug("Loading JasperDesign for :{}", _instance);
final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext.getInstance();
final JRXmlLoader loader = new JRXmlLoader(reportContext,
JRXmlDigesterFactory.createDigester(reportContext));
jasperDesign = loader.loadXML(source);
} catch (final ParserConfigurationException e) {
throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
} catch (final SAXException e) {
throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
} catch (final JRException e) {
throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
}
return jasperDesign;
} | java | {
"resource": ""
} |
q18857 | Reflections.getRawType | train | @SuppressWarnings("unckecked")
public static Class<?> getRawType(Type type) {
if (type instanceof Class<?>) {
// type is a normal class.
return (Class<?>) type;
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
// I'm not exactly sure why getRawType() returns Type instead of Class.
// Neal isn't either but suspects some pathological case related
// to nested classes exists.
Type rawType = parameterizedType.getRawType();
checkArgument(rawType instanceof Class,
"Expected a Class, but <%s> is of type %s", type, type.getClass().getName());
//noinspection ConstantConditions
return (Class<?>) rawType;
} else if (type instanceof GenericArrayType) {
Type componentType = ((GenericArrayType) type).getGenericComponentType();
return Array.newInstance(getRawType(componentType), 0).getClass();
} else if (type instanceof TypeVariable) {
// we could use the variable's bounds, but that'll won't work if there are multiple.
// having a raw type that's more general than necessary is okay
return Object.class;
} else {
throw new IllegalArgumentException("Expected a Class, ParameterizedType, or "
+ "GenericArrayType, but <" + type + "> is of type " + type.getClass().getName());
}
} | java | {
"resource": ""
} |
q18858 | TedDaoPostgres.eventQueueReserveTask | train | public TaskRec eventQueueReserveTask(long taskId) {
String sqlLogId = "reserve_task";
String sql = "update tedtask set status = 'WORK', startTs = $now, nextTs = null"
+ " where status in ('NEW','RETRY') and system = '$sys'"
+ " and taskid in ("
+ " select taskid from tedtask "
+ " where status in ('NEW','RETRY') and system = '$sys'"
+ " and taskid = ?"
+ " for update skip locked"
+ ") returning tedtask.*"
;
sql = sql.replace("$now", dbType.sql.now());
sql = sql.replace("$sys", thisSystem);
List<TaskRec> tasks = selectData(sqlLogId, sql, TaskRec.class, asList(
sqlParam(taskId, JetJdbcParamType.LONG)
));
return tasks.isEmpty() ? null : tasks.get(0);
} | java | {
"resource": ""
} |
q18859 | Field.initialize | train | public static void initialize()
{
if (InfinispanCache.get().exists(Field.IDCACHE)) {
InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE).clear();
} else {
InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE);
InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE).addListener(new CacheLogListener(Field.LOG));
}
} | java | {
"resource": ""
} |
q18860 | LRExporter.configure | train | public void configure() throws LRException
{
// Trim or nullify strings
nodeHost = StringUtil.nullifyBadInput(nodeHost);
publishAuthUser = StringUtil.nullifyBadInput(publishAuthUser);
publishAuthPassword = StringUtil.nullifyBadInput(publishAuthPassword);
// Throw an exception if any of the required fields are null
if (nodeHost == null)
{
throw new LRException(LRException.NULL_FIELD);
}
// Throw an error if the batch size is zero
if (batchSize == 0)
{
throw new LRException(LRException.BATCH_ZERO);
}
this.batchSize = batchSize;
this.publishFullUrl = publishProtocol + "://" + nodeHost + publishServiceUrl;
this.publishAuthUser = publishAuthUser;
this.publishAuthPassword = publishAuthPassword;
this.configured = true;
} | java | {
"resource": ""
} |
q18861 | LRExporter.addDocument | train | public void addDocument(LREnvelope envelope) throws LRException
{
if(!configured)
{
throw new LRException(LRException.NOT_CONFIGURED);
}
docs.add(envelope.getSendableData());
} | java | {
"resource": ""
} |
q18862 | Request.forward | train | public void forward(String controllerName) throws Throwable {
SilentGo instance = SilentGo.me();
((ActionChain) instance.getConfig().getActionChain().getObject()).doAction(instance.getConfig().getCtx().get().getActionParam());
} | java | {
"resource": ""
} |
q18863 | XSSFSheetXMLHandlerPlus.characters | train | @Override
public void characters(char[] ch, int start, int length)
throws SAXException {
if (vIsOpen) {
value.append(ch, start, length);
}
if (fIsOpen) {
formula.append(ch, start, length);
}
if (hfIsOpen) {
headerFooter.append(ch, start, length);
}
} | java | {
"resource": ""
} |
q18864 | XSSFSheetXMLHandlerPlus.checkForEmptyCellComments | train | private void checkForEmptyCellComments(XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType type) {
if (commentCellRefs != null && !commentCellRefs.isEmpty()) {
// If we've reached the end of the sheet data, output any
// comments we haven't yet already handled
if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_SHEET_DATA) {
while (!commentCellRefs.isEmpty()) {
outputEmptyCellComment(commentCellRefs.remove());
}
return;
}
// At the end of a row, handle any comments for "missing" rows before us
if (this.cellRef == null) {
if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_ROW) {
while (!commentCellRefs.isEmpty()) {
if (commentCellRefs.peek().getRow() == rowNum) {
outputEmptyCellComment(commentCellRefs.remove());
} else {
return;
}
}
return;
} else {
throw new IllegalStateException(
"Cell ref should be null only if there are only empty cells in the row; rowNum: " + rowNum);
}
}
CellAddress nextCommentCellRef;
do {
CellAddress cellRef = new CellAddress(this.cellRef);
CellAddress peekCellRef = commentCellRefs.peek();
if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.CELL && cellRef.equals(peekCellRef)) {
// remove the comment cell ref from the list if we're about to handle it alongside the cell content
commentCellRefs.remove();
return;
} else {
// fill in any gaps if there are empty cells with comment mixed in with non-empty cells
int comparison = peekCellRef.compareTo(cellRef);
if (comparison > 0 && type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_ROW &&
peekCellRef.getRow() <= rowNum) {
nextCommentCellRef = commentCellRefs.remove();
outputEmptyCellComment(nextCommentCellRef);
} else if (comparison < 0 && type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.CELL &&
peekCellRef.getRow() <= rowNum) {
nextCommentCellRef = commentCellRefs.remove();
outputEmptyCellComment(nextCommentCellRef);
} else {
nextCommentCellRef = null;
}
}
} while (nextCommentCellRef != null && !commentCellRefs.isEmpty());
}
} | java | {
"resource": ""
} |
q18865 | XSSFSheetXMLHandlerPlus.outputEmptyCellComment | train | private void outputEmptyCellComment(CellAddress cellRef) {
XSSFComment comment = commentsTable.findCellComment(cellRef);
output.cell(cellRef.formatAsString(), null, comment);
} | java | {
"resource": ""
} |
q18866 | GeometryIndexService.format | train | public String format(GeometryIndex index) {
if (index.hasChild()) {
return "geometry" + index.getValue() + "." + format(index.getChild());
}
switch (index.getType()) {
case TYPE_VERTEX:
return "vertex" + index.getValue();
case TYPE_EDGE:
return "edge" + index.getValue();
default:
return "geometry" + index.getValue();
}
} | java | {
"resource": ""
} |
q18867 | GeometryIndexService.getVertex | train | public Coordinate getVertex(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException {
if (index.hasChild()) {
if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) {
return getVertex(geometry.getGeometries()[index.getValue()], index.getChild());
}
throw new GeometryIndexNotFoundException("Could not match index with given geometry");
}
if (index.getType() == GeometryIndexType.TYPE_VERTEX && geometry.getCoordinates() != null
&& geometry.getCoordinates().length > index.getValue() && index.getValue() >= 0) {
return geometry.getCoordinates()[index.getValue()];
}
throw new GeometryIndexNotFoundException("Could not match index with given geometry");
} | java | {
"resource": ""
} |
q18868 | GeometryIndexService.isVertex | train | public boolean isVertex(GeometryIndex index) {
if (index.hasChild()) {
return isVertex(index.getChild());
}
return index.getType() == GeometryIndexType.TYPE_VERTEX;
} | java | {
"resource": ""
} |
q18869 | GeometryIndexService.isEdge | train | public boolean isEdge(GeometryIndex index) {
if (index.hasChild()) {
return isEdge(index.getChild());
}
return index.getType() == GeometryIndexType.TYPE_EDGE;
} | java | {
"resource": ""
} |
q18870 | GeometryIndexService.isGeometry | train | public boolean isGeometry(GeometryIndex index) {
if (index.hasChild()) {
return isGeometry(index.getChild());
}
return index.getType() == GeometryIndexType.TYPE_GEOMETRY;
} | java | {
"resource": ""
} |
q18871 | GeometryIndexService.getType | train | public GeometryIndexType getType(GeometryIndex index) {
if (index.hasChild()) {
return getType(index.getChild());
}
return index.getType();
} | java | {
"resource": ""
} |
q18872 | GeometryIndexService.getGeometryType | train | public String getGeometryType(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException {
if (index != null && index.getType() == GeometryIndexType.TYPE_GEOMETRY) {
if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) {
return getGeometryType(geometry.getGeometries()[index.getValue()], index.getChild());
} else {
throw new GeometryIndexNotFoundException("Can't find the geometry referred to in the given index.");
}
}
return geometry.getGeometryType();
} | java | {
"resource": ""
} |
q18873 | GeometryIndexService.getValue | train | public int getValue(GeometryIndex index) {
if (index.hasChild()) {
return getValue(index.getChild());
}
return index.getValue();
} | java | {
"resource": ""
} |
q18874 | GeometryIndexService.getParent | train | public GeometryIndex getParent(GeometryIndex index) {
GeometryIndex parent = new GeometryIndex(index);
GeometryIndex deepestParent = null;
GeometryIndex p = parent;
while (p.hasChild()) {
deepestParent = p;
p = p.getChild();
}
if (deepestParent != null) {
deepestParent.setChild(null);
}
return parent;
} | java | {
"resource": ""
} |
q18875 | GeometryIndexService.getNextVertex | train | public GeometryIndex getNextVertex(GeometryIndex index) {
if (index.hasChild()) {
return new GeometryIndex(index.getType(), index.getValue(), getNextVertex(index.getChild()));
} else {
return new GeometryIndex(GeometryIndexType.TYPE_VERTEX, index.getValue() + 1, null);
}
} | java | {
"resource": ""
} |
q18876 | GeometryIndexService.getSiblingVertices | train | public Coordinate[] getSiblingVertices(Geometry geometry, GeometryIndex index)
throws GeometryIndexNotFoundException {
if (index.hasChild() && geometry.getGeometries() != null &&
geometry.getGeometries().length > index.getValue()) {
return getSiblingVertices(geometry.getGeometries()[index.getValue()], index.getChild());
}
switch (index.getType()) {
case TYPE_VERTEX:
case TYPE_EDGE:
return geometry.getCoordinates();
case TYPE_GEOMETRY:
default:
throw new GeometryIndexNotFoundException("Given index is of wrong type. Can't find sibling vertices "
+ "for a geometry type of index.");
}
} | java | {
"resource": ""
} |
q18877 | LeetLevel.fromString | train | public static LeetLevel fromString(String str)
throws Exception {
if (str == null || str.equalsIgnoreCase("null") || str.length() == 0)
return LEVEL1;
try {
int i = Integer.parseInt(str);
if (i >= 1 && i <= LEVELS.length)
return LEVELS[i - 1];
} catch (Exception ignored) {}
String exceptionStr = String.format("Invalid LeetLevel '%1s', valid values are '1' to '9'", str);
throw new Exception(exceptionStr);
} | java | {
"resource": ""
} |
q18878 | LocalVariableTypeTable.addLocalTypeVariable | train | public void addLocalTypeVariable(VariableElement ve, String signature, int index)
{
localTypeVariables.add(new LocalTypeVariable(ve, signature, index));
} | java | {
"resource": ""
} |
q18879 | FileSplitter.writePartToFile | train | private static File writePartToFile(File splitDir, List<String> data) {
BufferedWriter writer = null;
File splitFile;
try {
splitFile = File.createTempFile("split-", ".part", splitDir);
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(splitFile.getAbsoluteFile(), false),
DataUtilDefaults.charSet));
for(String item : data) {
writer.write(item + DataUtilDefaults.lineTerminator);
}
writer.flush();
writer.close();
writer = null;
} catch (UnsupportedEncodingException e) {
throw new DataUtilException(e);
} catch (FileNotFoundException e) {
throw new DataUtilException(e);
} catch (IOException e) {
throw new DataUtilException(e);
} finally {
if(writer != null) {
try {
writer.close();
} catch (IOException e) {
// Intentionally we're doing nothing here
}
}
}
return splitFile;
} | java | {
"resource": ""
} |
q18880 | FileSplitter.storageCalculation | train | private static long storageCalculation(int rows, int lineChars, long totalCharacters) {
long size = (long) Math.ceil((rows* ARRAY_LIST_ROW_OVERHEAD + lineChars + totalCharacters) * LIST_CAPACITY_MULTIPLIER);
return size;
} | java | {
"resource": ""
} |
q18881 | MultipartParser.extractBoundary | train | private String extractBoundary(String line) {
// Use lastIndexOf() because IE 4.01 on Win98 has been known to send the
// "boundary=" string multiple times. Thanks to David Wall for this fix.
int index = line.lastIndexOf("boundary=");
if (index == -1) {
return null;
}
String boundary = line.substring(index + 9); // 9 for "boundary="
if (boundary.charAt(0) == '"') {
// The boundary is enclosed in quotes, strip them
index = boundary.lastIndexOf('"');
boundary = boundary.substring(1, index);
}
// The real boundary is always preceeded by an extra "--"
boundary = "--" + boundary;
return boundary;
} | java | {
"resource": ""
} |
q18882 | MultipartParser.extractContentType | train | private static String extractContentType(String line) throws IOException {
// Convert the line to a lowercase string
line = line.toLowerCase();
// Get the content type, if any
// Note that Opera at least puts extra info after the type, so handle
// that. For example: Content-Type: text/plain; name="foo"
// Thanks to Leon Poyyayil, leon.poyyayil@trivadis.com, for noticing this.
int end = line.indexOf(";");
if (end == -1) {
end = line.length();
}
return line.substring(13, end).trim(); // "content-type:" is 13
} | java | {
"resource": ""
} |
q18883 | MultipartParser.readLine | train | private String readLine() throws IOException {
StringBuffer sbuf = new StringBuffer();
int result;
String line;
do {
result = in.readLine(buf, 0, buf.length); // does +=
if (result != -1) {
sbuf.append(new String(buf, 0, result, encoding));
}
} while (result == buf.length); // loop only if the buffer was filled
if (sbuf.length() == 0) {
return null; // nothing read, must be at the end of stream
}
// Cut off the trailing \n or \r\n
// It should always be \r\n but IE5 sometimes does just \n
// Thanks to Luke Blaikie for helping make this work with \n
int len = sbuf.length();
if (len >= 2 && sbuf.charAt(len - 2) == '\r') {
sbuf.setLength(len - 2); // cut \r\n
}
else if (len >= 1 && sbuf.charAt(len - 1) == '\n') {
sbuf.setLength(len - 1); // cut \n
}
return sbuf.toString();
} | java | {
"resource": ""
} |
q18884 | SnomedMetadata.getNeverGroupedIds | train | public Set<String> getNeverGroupedIds() {
String s = props.getProperty("neverGroupedIds");
if(s == null) return Collections.emptySet();
Set<String> res = new HashSet<String>();
String[] parts = s.split("[,]");
for(String part : parts) {
res.add(part);
}
return res;
} | java | {
"resource": ""
} |
q18885 | SnomedMetadata.getRightIdentityIds | train | public Map<String, String> getRightIdentityIds() {
String s = props.getProperty("rightIdentityIds");
if(s == null) return Collections.emptyMap();
Map<String, String> res = new HashMap<String, String>();
String[] parts = s.split("[,]");
res.put(parts[0], parts[1]);
return res;
} | java | {
"resource": ""
} |
q18886 | Base64Serializer.serialize | train | public String serialize(Object object) {
ObjectOutputStream oos = null;
ByteArrayOutputStream bos = null;
try {
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
oos.writeObject(object);
return new String(Base64.encodeBase64(bos.toByteArray()));
} catch (IOException e) {
LOGGER.error("Can't serialize data on Base 64", e);
throw new IllegalArgumentException(e);
} catch (Exception e) {
LOGGER.error("Can't serialize data on Base 64", e);
throw new IllegalArgumentException(e);
} finally {
try {
if (bos != null) {
bos.close();
}
} catch (Exception e) {
LOGGER.error("Can't close ObjetInputStream used for serialize data on Base 64", e);
}
}
} | java | {
"resource": ""
} |
q18887 | Base64Serializer.deserialize | train | public Object deserialize(String data) {
if ((data == null) || (data.length() == 0)) {
return null;
}
ObjectInputStream ois = null;
ByteArrayInputStream bis = null;
try {
bis = new ByteArrayInputStream(Base64.decodeBase64(data.getBytes()));
ois = new ObjectInputStream(bis);
return ois.readObject();
} catch (ClassNotFoundException e) {
LOGGER.error("Can't deserialize data from Base64", e);
throw new IllegalArgumentException(e);
} catch (IOException e) {
LOGGER.error("Can't deserialize data from Base64", e);
throw new IllegalArgumentException(e);
} catch (Exception e) {
LOGGER.error("Can't deserialize data from Base64", e);
throw new IllegalArgumentException(e);
} finally {
try {
if (ois != null) {
ois.close();
}
} catch (Exception e) {
LOGGER.error("Can't close ObjetInputStream used for deserialize data from Base64", e);
}
}
} | java | {
"resource": ""
} |
q18888 | ClassFile.getMethodIndex | train | int getMethodIndex(ExecutableElement method)
{
TypeElement declaringClass = (TypeElement) method.getEnclosingElement();
String fullyQualifiedname = declaringClass.getQualifiedName().toString();
return getRefIndex(Methodref.class, fullyQualifiedname, method.getSimpleName().toString(), Descriptor.getDesriptor(method));
} | java | {
"resource": ""
} |
q18889 | ClassFile.getRefIndex | train | protected int getRefIndex(Class<? extends Ref> refType, String fullyQualifiedname, String name, String descriptor)
{
String internalForm = fullyQualifiedname.replace('.', '/');
for (ConstantInfo ci : listConstantInfo(refType))
{
Ref mr = (Ref) ci;
int classIndex = mr.getClass_index();
Clazz clazz = (Clazz) getConstantInfo(classIndex);
String cn = getString(clazz.getName_index());
if (internalForm.equals(cn))
{
int nameAndTypeIndex = mr.getName_and_type_index();
NameAndType nat = (NameAndType) getConstantInfo(nameAndTypeIndex);
int nameIndex = nat.getName_index();
String str = getString(nameIndex);
if (name.equals(str))
{
int descriptorIndex = nat.getDescriptor_index();
String descr = getString(descriptorIndex);
if (descriptor.equals(descr))
{
return constantPoolIndexMap.get(ci);
}
}
}
}
return -1;
} | java | {
"resource": ""
} |
q18890 | ClassFile.getNameIndex | train | public int getNameIndex(CharSequence name)
{
for (ConstantInfo ci : listConstantInfo(Utf8.class))
{
Utf8 utf8 = (Utf8) ci;
String str = utf8.getString();
if (str.contentEquals(name))
{
return constantPoolIndexMap.get(ci);
}
}
return -1;
} | java | {
"resource": ""
} |
q18891 | ClassFile.getNameAndTypeIndex | train | public int getNameAndTypeIndex(String name, String descriptor)
{
for (ConstantInfo ci : listConstantInfo(NameAndType.class))
{
NameAndType nat = (NameAndType) ci;
int nameIndex = nat.getName_index();
String str = getString(nameIndex);
if (name.equals(str))
{
int descriptorIndex = nat.getDescriptor_index();
String descr = getString(descriptorIndex);
if (descriptor.equals(descr))
{
return constantPoolIndexMap.get(ci);
}
}
}
return -1;
} | java | {
"resource": ""
} |
q18892 | ClassFile.getConstantIndex | train | public final int getConstantIndex(int constant)
{
for (ConstantInfo ci : listConstantInfo(ConstantInteger.class))
{
ConstantInteger ic = (ConstantInteger) ci;
if (constant == ic.getConstant())
{
return constantPoolIndexMap.get(ci);
}
}
return -1;
} | java | {
"resource": ""
} |
q18893 | ClassFile.getIndexedType | train | Object getIndexedType(int index)
{
Object ae = indexedElementMap.get(index);
if (ae == null)
{
throw new VerifyError("constant pool at "+index+" not proper type");
}
return ae;
} | java | {
"resource": ""
} |
q18894 | ClassFile.getFieldDescription | train | public String getFieldDescription(int index)
{
ConstantInfo constantInfo = getConstantInfo(index);
if (constantInfo instanceof Fieldref)
{
Fieldref fr = (Fieldref) getConstantInfo(index);
int nt = fr.getName_and_type_index();
NameAndType nat = (NameAndType) getConstantInfo(nt);
int ni = nat.getName_index();
int di = nat.getDescriptor_index();
return getString(ni)+" "+getString(di);
}
return "unknown "+constantInfo;
} | java | {
"resource": ""
} |
q18895 | ClassFile.getMethodDescription | train | public String getMethodDescription(int index)
{
ConstantInfo constantInfo = getConstantInfo(index);
if (constantInfo instanceof Methodref)
{
Methodref mr = (Methodref) getConstantInfo(index);
int nt = mr.getName_and_type_index();
NameAndType nat = (NameAndType) getConstantInfo(nt);
int ni = nat.getName_index();
int di = nat.getDescriptor_index();
return getString(ni)+" "+getString(di);
}
if (constantInfo instanceof InterfaceMethodref)
{
InterfaceMethodref mr = (InterfaceMethodref) getConstantInfo(index);
int nt = mr.getName_and_type_index();
NameAndType nat = (NameAndType) getConstantInfo(nt);
int ni = nat.getName_index();
int di = nat.getDescriptor_index();
return getString(ni)+" "+getString(di);
}
return "unknown "+constantInfo;
} | java | {
"resource": ""
} |
q18896 | ClassFile.getClassDescription | train | public String getClassDescription(int index)
{
Clazz cz = (Clazz) getConstantInfo(index);
int ni = cz.getName_index();
return getString(ni);
} | java | {
"resource": ""
} |
q18897 | ClassFile.referencesMethod | train | public boolean referencesMethod(ExecutableElement method)
{
TypeElement declaringClass = (TypeElement) method.getEnclosingElement();
String fullyQualifiedname = declaringClass.getQualifiedName().toString();
String name = method.getSimpleName().toString();
assert name.indexOf('.') == -1;
String descriptor = Descriptor.getDesriptor(method);
return getRefIndex(Methodref.class, fullyQualifiedname, name, descriptor) != -1;
} | java | {
"resource": ""
} |
q18898 | ClassFile.getString | train | public final String getString(int index)
{
Utf8 utf8 = (Utf8) getConstantInfo(index);
return utf8.getString();
} | java | {
"resource": ""
} |
q18899 | El.getMethod | train | public static ExecutableElement getMethod(TypeElement typeElement, String name, TypeMirror... parameters)
{
List<ExecutableElement> allMethods = getAllMethods(typeElement, name, parameters);
if (allMethods.isEmpty())
{
return null;
}
else
{
Collections.sort(allMethods, new SpecificMethodComparator());
return allMethods.get(0);
}
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.