code
stringlengths
73
34.1k
label
stringclasses
1 value
private static String recursiveSearch(java.io.File dir, String fileName) { for (String name : dir.list()) { java.io.File file = new java.io.File(dir.getAbsolutePath() + "/" + name); if (name.compareTo(fileName) == 0) return file.getAbsolutePath(); if (file.isDirectory()) { ...
java
public static void touch(File file) throws FileNotFoundException { if (!file.exists()) { OutputStream out = new FileOutputStream(file); try { out.close(); } catch (IOException e) { // Ignore. } } file.setLastModifi...
java
public boolean isType(final org.efaps.admin.datamodel.Type _type) { return getType().equals(_type); }
java
public void rotation(TextureRotationMode mode){ float[][] tmp = corner.clone(); switch (mode) { case HALF: corner[0] = tmp[2]; corner[1] = tmp[3]; corner[2] = tmp[0]; corner[3] = tmp[1]; break; case CLOCKWIZE: corner[0] = tmp[3]; corner[1] = tmp[0]; corner[2] = tmp[1]; corner[3] = tmp...
java
public void flip(TextureFlipMode mode){ float[][] tmp = corner.clone(); switch (mode) { case VERTICAL: corner[0] = tmp[1]; corner[1] = tmp[0]; corner[2] = tmp[3]; corner[3] = tmp[2]; break; case HORIZONTAL: corner[0] = tmp[3]; corner[1] = tmp[2]; corner[2] = tmp[1]; corner[3] = tmp[0]...
java
public void addObject(final Object[] _row) throws EFapsException { this.objects.add(this.elements.get(0).getObject(_row)); }
java
public void resolve() throws InstallationException { final IvySettings ivySettings = new IvySettings(); try { ivySettings.load(this.getClass().getResource("/org/efaps/update/version/ivy.xml")); } catch (final IOException e) { throw new InstallationException(...
java
private void compileJasperReport(final Instance _instSource, final Instance _instCompiled) throws EFapsException { // make the classPath final String sep = System.getProperty("os.name").startsWith("Windows") ? ";" : ":"; final StringBuilder classP...
java
protected void registerEQLStmt(final String _origin, final String _stmt) throws EFapsException { // Common_HistoryEQL final Insert insert = new Insert(UUID.fromString("c96c63b5-2d4c-4bf9-9627-f335fd9c7a84")); insert.add("Origin", "REST: " + (_origin...
java
@Override public Object getValue(final Object _object) throws EFapsException { final Instance inst = (Instance) super.getValue(_object); if (this.esjp == null) { try { final Class<?> clazz = Class.forName(this.className, false, EFapsClassLoader.getInstance());...
java
@Override protected String evalApplication() { String ret = null; final Pattern revisionPattern = Pattern.compile("@eFapsApplication[\\s].*"); final Matcher revisionMatcher = revisionPattern.matcher(getCode()); if (revisionMatcher.find()) { ret = revisionMatcher.group...
java
@Override protected UUID evalUUID() { UUID uuid = null; final Pattern uuidPattern = Pattern.compile("@eFapsUUID[\\s]*[0-9a-z\\-]*"); final Matcher uuidMatcher = uuidPattern.matcher(getCode()); if (uuidMatcher.find()) { final String uuidStr = uuidMatcher.group().repla...
java
protected String evalExtends() { String ret = null; // regular expression for the package name final Pattern exPattern = Pattern.compile("@eFapsExtends[\\s]*[a-zA-Z\\._-]*\\b"); final Matcher exMatcher = exPattern.matcher(getCode()); if (exMatcher.find()) { ret = ...
java
public void setBackground(float x, float y, float z, float a) { gl.glClearColor(x / 255, y / 255, z / 255, a / 255); }
java
public void setBackgroud(Color color) { gl.glClearColor((float)color.getRed(), (float)color.getGreen(), (float)color.getBlue(), (float)(color.getAlpha() * getAlpha())); }
java
public void matrixMode(MatrixMode mode) { switch (mode) { case PROJECTION: gl.glMatrixMode(GL2.GL_PROJECTION); break; case MODELVIEW: gl.glMatrixMode(GL2.GL_MODELVIEW); break; default: break; } }
java
public void setAmbientLight(float r, float g, float b) { float ambient[] = { r, g, b, 255 }; normalize(ambient); gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_LIGHT0); gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0); }
java
public void setAmbientLight(int i, Color color, boolean enableColor) { float ambient[] = { (float)color.getRed(), (float)color.getGreen(), (float)color.getBlue(), (float)color.getAlpha() }; gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_LIGHT0 + i...
java
public void setAmbientLight(int i, Color color, boolean enableColor, Vector3D v) { float ambient[] = { (float)color.getRed(), (float)color.getGreen(), (float)color.getBlue(), (float)color.getAlpha() }; float position[] = { (float)v.getX(), (floa...
java
public void setSpotLight(int i, Color color, boolean enableColor, Vector3D v, float nx, float ny, float nz, float angle) { float spotColor[] = { (float)color.getRed(), (float)color.getGreen(), (float)color.getBlue(), (float)color.getAlpha() }; float po...
java
public void setLightAttenuation(int i, float constant, float liner, float quadratic) { float c[] = { constant }; float l[] = { liner }; float q[] = { quadratic }; gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_LIGHT0 + i); gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_CONSTANT_ATTENUATION, c, 0); gl.glL...
java
public void setLightSpecular(int i, Color color) { float[] tmpColor = { (float)color.getRed(), (float)color.getGreen(), (float)color.getBlue(), (float)color.getAlpha() }; gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_SPECULAR, tmpColor, 0); }
java
public void setLightDiffuse(int i, Color color) { float[] tmpColor = { (float)color.getRed(), (float)color.getGreen(), (float)color.getBlue(), (float)color.getAlpha() }; gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_DIFFUSE, tmpColor, 0); }
java
private static float[] normalize(float[] in) { float[] out = new float[in.length]; for (int i = 0; i < in.length; i++) { out[i] = (in[i] / 255.0f); } return out; }
java
public void setPerspective(double fov, double aspect, double zNear, double zFar) { matrixMode(MatrixMode.PROJECTION); resetMatrix(); glu.gluPerspective(fov, aspect, zNear, zFar); matrixMode(MatrixMode.MODELVIEW); resetMatrix(); }
java
public void setPerspective() { double cameraZ = ((height / 2.0) / Math.tan(Math.PI * 60.0 / 360.0)); matrixMode(MatrixMode.PROJECTION); resetMatrix(); glu.gluPerspective(Math.PI / 3.0, this.width / this.height, cameraZ / 10.0, cameraZ * 10.0); matrixMode(MatrixMode.MODELVIEW); resetMatrix(); }
java
public void setOrtho(double left, double right, double bottom, double top, double near, double far) { matrixMode(MatrixMode.PROJECTION); resetMatrix(); gl.glOrtho(left, right, bottom, top, near, far); matrixMode(MatrixMode.MODELVIEW); resetMatrix(); }
java
public void setOrtho() { matrixMode(MatrixMode.PROJECTION); resetMatrix(); gl.glOrtho(0, this.width, 0, this.height, -1.0e10, 1.0e10); matrixMode(MatrixMode.MODELVIEW); resetMatrix(); }
java
public void setFrustum(double left, double right, double bottom, double top, double near, double far) { matrixMode(MatrixMode.PROJECTION); resetMatrix(); gl.glFrustum(left, right, bottom, top, near, far); matrixMode(MatrixMode.MODELVIEW); resetMatrix(); }
java
public void setCamera() { glu.gluLookAt(width / 2.0, height / 2.0, (height / 2.0) / Math.tan(Math.PI * 60.0 / 360.0), width / 2.0, height / 2.0, 0, 0, 1, 0); }
java
public Key getKey() { final Key ret = new Key().setPersonId(getPersonId()) .setCompanyId(getCompanyId()) .setTypeId(getTypeId()); return ret; }
java
@Override public String getTag() throws IOException { URLConnection urlConnection = url.openConnection(); String tag = urlConnection.getHeaderField(ETAG); if(tag == null) { String key = url.toString() + "@" + urlConnection.getLastModified(); tag = md5Cache.getIfPresent(key); ...
java
private List<Pair<Id, GuiceSupplier>> getSuppliers() { ImmutableList.Builder<Pair<Id, GuiceSupplier>> suppliersBuilder = ImmutableList.builder(); for (Binding<GuiceRegistration> registrationBinding : injector.findBindingsByType(TypeLiteral.get(GuiceRegistration.class))) { Key<?> key = regist...
java
public SQLSelect column(final String _name) { columns.add(new Column(tablePrefix, null, _name)); return this; }
java
public int columnIndex(final int _tableIndex, final String _columnName) { final Optional<Column> colOpt = getColumns().stream() .filter(column -> column.tableIndex == _tableIndex && column.columnName.equals(_columnName)) .findFirst(); final int ret; ...
java
public String getSQL() { final StringBuilder cmd = new StringBuilder().append(" ") .append(Context.getDbType().getSQLPart(SQLPart.SELECT)).append(" "); if (distinct) { cmd.append(Context.getDbType().getSQLPart(SQLPart.DISTINCT)).append(" "); } boolean first = ...
java
public SQLSelect addColumnPart(final Integer _tableIndex, final String _columnName) { parts.add(new Column(tablePrefix, _tableIndex, _columnName)); return this; }
java
public SQLSelect addTablePart(final String _tableName, final Integer _tableIndex) { parts.add(new FromTable(tablePrefix, _tableName, _tableIndex)); return this; }
java
public SQLSelect addTimestampValue(final String _isoDateTime) { parts.add(new Value(Context.getDbType().getTimestampValue(_isoDateTime))); return this; }
java
public static CachedPrintQuery get4Request(final Instance _instance) throws EFapsException { return new CachedPrintQuery(_instance, Context.getThreadContext().getRequestId()).setLifespan(5) .setLifespanUnit(TimeUnit.MINUTES); }
java
@Override protected void prepare(final AbstractSQLInsertUpdate<?> _insertUpdate, final Attribute _attribute, final Object... _values) throws SQLException { checkSQLColumnSize(_attribute, 1); try { _insertUpdate.column(_att...
java
protected void addMapping(final ColumnType _columnType, final String _writeTypeName, final String _nullValueSelect, final String... _readTypeNames) { this.writeColTypeMap.put(_columnType, _writeTypeName); this....
java
public boolean existsView(final Connection _con, final String _viewName) throws SQLException { boolean ret = false; final DatabaseMetaData metaData = _con.getMetaData(); // first test with lower case final ResultSet rs = metaData.getTables(null...
java
public T updateColumn(final Connection _con, final String _tableName, final String _columnName, final ColumnType _columnType, final int _length, final int _scale) throws SQLException...
java
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...
java
public T addForeignKey(final Connection _con, final String _tableName, final String _foreignKeyName, final String _key, final String _reference, final boolean _cascade) throws I...
java
public void addCheckKey(final Connection _con, final String _tableName, final String _checkKeyName, final String _condition) throws SQLException { final StringBuilder cmd = new StringBuilder() ...
java
public static AbstractDatabase<?> findByClassName(final String _dbClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { return (AbstractDatabase<?>) Class.forName(_dbClassName).newInstance(); }
java
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
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.ge...
java
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
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) { ...
java
public static List<Instance> getInstances(final AbstractQueryPart _queryPart) throws EFapsException { return getQueryBldr(_queryPart).getQuery().execute(); }
java
public static BigDecimal parseLocalized(final String _value) throws EFapsException { final DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(Context.getThreadContext() .getLocale()); format.setParseBigDecimal(true); try { return (BigDecimal) ...
java
public void update(String cacheName, Cache cache) { cacheManager.enableManagement(cacheName, cache.isManagementEnabled()); updateStatistics(cacheName, cache); }
java
public void setStatistics(boolean enabled) { all().forEach(cache -> updateStatistics(cache.getName(), new Cache(false, enabled))); }
java
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)).isStatisticsEnab...
java
private void setAttrValue(final AttrName _attrName, final String _value) { synchronized (this.attrValues) { this.attrValues.put(_attrName, _value); } }
java
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) { ...
java
public String getLanguage() { return this.attrValues.get(Person.AttrName.LANGUAGE) != null ? this.attrValues.get(Person.AttrName.LANGUAGE) : Locale.ENGLISH.getISO3Language(); }
java
public DateTimeZone getTimeZone() { return this.attrValues.get(Person.AttrName.TIMZONE) != null ? DateTimeZone.forID(this.attrValues.get(Person.AttrName.TIMZONE)) : DateTimeZone.UTC; }
java
public ChronologyType getChronologyType() { final String chronoKey = this.attrValues.get(Person.AttrName.CHRONOLOGY); final ChronologyType chronoType; if (chronoKey != null) { chronoType = ChronologyType.getByKey(chronoKey); } else { chronoType = ChronologyTyp...
java
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, ...
java
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 = EFapsSyst...
java
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("upda...
java
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 U...
java
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); ...
java
private void readFromDBAttributes() throws EFapsException { Connection con = null; try { con = Context.getConnection(); Statement stmt = null; try { stmt = con.createStatement(); final StringBuilder cmd = new StringBuilder(...
java
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...
java
public void assignGroupInDb(final JAASSystem _jaasSystem, final Group _group) throws EFapsException { assignToUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group); }
java
public void unassignGroupInDb(final JAASSystem _jaasSystem, final Group _group) throws EFapsException { unassignFromUserObjectInDb(CIAdminUser.Person2Group.getType(), _jaasSystem, _group); }
java
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) { Infinispan...
java
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 { ...
java
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
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
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
public MessageToSend prepareMessageToSend() { originalMessage.getParts().clear(); originalMessage.getParts().addAll(publicParts); return originalMessage; }
java
public ChatMessage createFinalMessage(MessageSentResponse response) { return ChatMessage.builder() .setMessageId(response.getId()) .setSentEventId(response.getEventId()) .setConversationId(conversationId) .setSentBy(sender) .setFrom...
java
private void addTables() { for (final SQLTable table : getType().getTables()) { if (!getTable2values().containsKey(table)) { getTable2values().put(table, new ArrayList<Value>()); } } }
java
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()...
java
public Insert setExchangeIds(final Long _exchangeSystemId, final Long _exchangeId) { this.exchangeSystemId = _exchangeSystemId; this.exchangeId = _exchangeId; return this; }
java
@Override public void executeWithoutTrigger() throws EFapsException { final Context context = Context.getThreadContext(); ConnectionResource con = null; try { con = context.getConnectionResource(); final SQLTable mainTable = getType().getMainTable(); ...
java
public static final Vector3D randVertex2d() { float theta = random((float)(Math.PI*2.0)); return new Vector3D(Math.cos(theta),Math.sin(theta)); }
java
@SuppressLint("UseSparseArrays") public void addStatusUpdate(ChatMessageStatus status) { int unique = (status.getMessageId() + status.getProfileId() + status.getMessageStatus().name()).hashCode(); if (statusUpdates == null) { statusUpdates = new HashMap<>(); } statusUpdat...
java
public static void put(Map<String,Object> structure, String name, Object object) { if (name != null && object != null) { structure.put(name, object); } }
java
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.NE...
java
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 ']': ...
java
public boolean isMatch(CharSequence text) { try { if (text.length() == 0) { return acceptEmpty; } InputReader reader = Input.getInstance(text); return isMatch(reader); } catch (IOException ex) ...
java
public boolean isMatch(PushbackReader input, int size) throws IOException { InputReader reader = Input.getInstance(input, size); return isMatch(reader); }
java
public boolean isMatch(InputReader reader) throws IOException { int rc = match(reader); return (rc == 1 && reader.read() == -1); }
java
public String match(CharSequence text) { try { if (text.length() == 0) { if (acceptEmpty) { return ""; } else { throw new SyntaxErrorException("...
java
public String lookingAt(CharSequence text) { try { if (text.length() == 0) { if (acceptEmpty) { return ""; } else { throw new SyntaxErrorExcepti...
java
public String replace(CharSequence text, CharSequence replacement) { try { if (text.length() == 0) { if (acceptEmpty) { return ""; } } CharArrayWriter caw = new CharArrayWri...
java
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...
java
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
public void replace(PushbackReader in, int bufferSize, Writer out, ObsoleteReplacer replacer) throws IOException { InputReader reader = Input.getInstance(in, bufferSize); replace(reader, out, replacer); }
java
public static Regex literal(String expression, Option... options) throws IOException { return compile(escape(expression), options); }
java
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
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...
java
Observable<List<ChatConversationBase>> loadAllConversations() { return Observable.create(emitter -> storeFactory.execute(new StoreTransaction<ChatStore>() { @Override protected void execute(ChatStore store) { store.open(); List<ChatConversationBase> conve...
java