id
stringlengths
7
14
text
stringlengths
1
106k
13899_11
public static String readString(InputStream in, String charset) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); int c; while ((c = in.read()) > 0) { out.write(c); } return new String(out.toByteArray(), charset); }
13899_12
public static byte[] encryptPassword(String password, byte[] salt) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] hash1 = md.digest(password.getBytes()); md.reset(); byte[] hash2 = md.digest(hash1); md.reset(); md.update(salt); md.update(hash2); byte[] digest = md.digest(); for (int i = 0; i < digest.length; i++) { digest[i] = (byte)(digest[i] ^ hash1[i]); } return digest; }
149511_0
public R execute(RevisionController revisionController, String pagePath) { return execute(revisionController, pagePath, new HashMap<String, String>()); }
149511_1
public R execute(RevisionController revisionController, String pagePath) { return execute(revisionController, pagePath, new HashMap<String, String>()); }
149511_2
public R execute(RevisionController revisionController, String pagePath) { return execute(revisionController, pagePath, new HashMap<String, String>()); }
149511_3
public R execute(RevisionController revisionController, String pagePath) { return execute(revisionController, pagePath, new HashMap<String, String>()); }
149511_4
public R execute(RevisionController revisionController, String pagePath) { return execute(revisionController, pagePath, new HashMap<String, String>()); }
149511_5
public R execute(RevisionController revisionController, String pagePath) { return execute(revisionController, pagePath, new HashMap<String, String>()); }
149511_6
public RevisionControlOperation[] operations() { return new RevisionControlOperation[]{CHECKIN, UPDATE, REVERT, STATUS}; }
149511_7
public RevisionControlOperation[] operations() { return new RevisionControlOperation[]{CHECKIN, UPDATE, REVERT, STATUS}; }
149511_8
public RevisionControlOperation[] operations() { return new RevisionControlOperation[]{CHECKIN, UPDATE, REVERT, STATUS}; }
149511_9
public RevisionControlOperation[] operations() { return new RevisionControlOperation[]{CHECKIN, UPDATE, REVERT, STATUS}; }
152134_0
public List<Point> points() { return Collections.unmodifiableList(plots); }
152134_1
public List<Point> points() { return Collections.unmodifiableList(plots); }
152134_2
public void plot(Point point) { plots.add(point); }
152134_3
public void plot(Point point) { plots.add(point); }
152134_4
public void plot(Point point) { plots.add(point); }
152134_5
public static List<Point> around(Point point) { List<Point> points = new ArrayList<Point>(); for (int x2 = point.x - 1; x2 <= point.x + 1; x2++) { for (int y2 = point.y - 1; y2 <= point.y + 1; y2++) { if (x2 != point.x || y2 != point.y) { points.add(new Point(x2, y2)); } } } return points; }
152134_6
public List<Person> findByLastname(String lastname) { try { Connection conn = datasource.getConnection(); String sql = "SELECT * FROM people WHERE last_name = ?"; PreparedStatement stmt = conn.prepareStatement(sql); stmt.setString(1, lastname); ResultSet rset = stmt.executeQuery(); List<Person> people = new ArrayList<Person>(); while (rset.next()) { String firstName = rset.getString("first_name"); String lastName = rset.getString("last_name"); people.add(new Person(firstName, lastName)); } rset.close(); stmt.close(); conn.close(); return people; } catch (SQLException e) { throw new RuntimeException(e); } }
152134_7
@SuppressWarnings("unchecked") public List<Person> findByLastname(String name) { try { Session session = sessionFactory.getCurrentSession(); String hql = "from Person p where p.lastname = :lastname"; Query query = session.createQuery(hql); query.setParameter("lastname", name); return query.list(); } catch (HibernateException e) { throw new RuntimeException(e); } }
152134_8
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString("first_name"), rs .getString("last_name")); }
152134_9
@SuppressWarnings("unchecked") public List<Person> findByLastName(String lastName) { String sql = "SELECT * FROM employee WHERE last_name = ?"; Object[] args = { lastName }; RowMapper mapper = new PersonRowMapper(); return getJdbcTemplate().query(sql, args, mapper); }
152812_0
private Object createProxy( final Class<?> targetClass, final Class<?>[] interfaces, final Callback[] callbacks ) { final Enhancer e = new Enhancer(); e.setInterfaces( interfaces ); e.setSuperclass( targetClass ); e.setCallbacks( callbacks ); return e.create(); }
152812_1
private Object createProxy( final Class<?> targetClass, final Class<?>[] interfaces, final Callback[] callbacks ) { final Enhancer e = new Enhancer(); e.setInterfaces( interfaces ); e.setSuperclass( targetClass ); e.setCallbacks( callbacks ); return e.create(); }
152812_2
@Override public Serializer newSerializer( final Class<?> type ) { if( HIBERNATE_ABSTRACT_COLLECTION_CLASS == null ) { return null; } else if ( HIBERNATE_ABSTRACT_COLLECTION_CLASS.isAssignableFrom( type ) ) { return new FieldSerializer( _kryo, type ); } return null; }
152812_3
public Kryo build() { return createKryo( classResolver != null ? classResolver : new DefaultClassResolver(), referenceResolver != null ? referenceResolver : new MapReferenceResolver(), streamFactory != null ? streamFactory : new DefaultStreamFactory() ); }
152812_4
protected String getSessionCookieName() { return _sessionCookieName; }
152812_5
@Override public void invoke( final Request request, final Response response ) throws IOException, ServletException { final Object processRequest = request.getNote(RequestTrackingHostValve.REQUEST_PROCESS); if(processRequest != Boolean.TRUE) { request.setNote(INVOKED, Boolean.TRUE); try { getNext().invoke( request, response ); } finally { request.setNote(RequestTrackingHostValve.REQUEST_PROCESSED, Boolean.TRUE); } } else { boolean sessionIdChanged = false; try { request.setNote(INVOKED, Boolean.TRUE); sessionIdChanged = changeRequestedSessionId( request, response ); getNext().invoke( request, response ); } finally { request.setNote(RequestTrackingHostValve.REQUEST_PROCESSED, Boolean.TRUE); request.setNote(RequestTrackingHostValve.SESSION_ID_CHANGED, Boolean.valueOf(sessionIdChanged)); } } }
152812_6
@Override public void invoke( final Request request, final Response response ) throws IOException, ServletException { final Object processRequest = request.getNote(RequestTrackingHostValve.REQUEST_PROCESS); if(processRequest != Boolean.TRUE) { request.setNote(INVOKED, Boolean.TRUE); try { getNext().invoke( request, response ); } finally { request.setNote(RequestTrackingHostValve.REQUEST_PROCESSED, Boolean.TRUE); } } else { boolean sessionIdChanged = false; try { request.setNote(INVOKED, Boolean.TRUE); sessionIdChanged = changeRequestedSessionId( request, response ); getNext().invoke( request, response ); } finally { request.setNote(RequestTrackingHostValve.REQUEST_PROCESSED, Boolean.TRUE); request.setNote(RequestTrackingHostValve.SESSION_ID_CHANGED, Boolean.valueOf(sessionIdChanged)); } } }
152812_7
public boolean isValid() { final long timeNow = System.currentTimeMillis(); final int timeIdle = (int) ((timeNow - _thisAccessedTime) / 1000L); // if tomcat session inactivity is negative or 0, session // should not expire return _maxInactiveInterval <= 0 || timeIdle < _maxInactiveInterval; }
152812_8
static byte[] serializeSessionFields( final MemcachedBackupSession session ) { return serializeSessionFields(session, VERSION_2); }
152812_9
public V remove( final K key ) { synchronized ( _map ) { final ManagedItem<V> removed = _map.remove( key ); return removed != null ? removed._value : null; } }
160996_0
private void wakeup( Alarm alarm ) { try { int delay = alarm.listener.wakeup( this, alarm.getState(), alarm.getDue() ); if (delay != 0) update( alarm, delay ); else remove( alarm ); } catch ( Exception e ) { remove( alarm ); report( e ); } }
160996_1
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_2
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_3
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_4
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_5
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_6
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_7
public synchronized void add( AlarmListener listener, Object state, int delay ) { if (listener == null) throw new NullPointerException( "listener == null" ); if (delay <= 0) throw new IllegalArgumentException( "delay <= 0" ); checkIsStarted(); long due = Timer.getNanos() + delay * Timer.NANOS_PER_MILLI; Alarm alarm = getAlarm( listener ); if (alarm != null) { // schedule is being adjusted dequeue( alarm ); alarm.setDue( due ); alarm.setState( state ); enqueue( alarm ); } else { alarm = new Alarm( listener, state, due ); addAlarm( listener, alarm ); enqueue( alarm ); } notifyWorker( "add" ); }
160996_8
public synchronized void remove( AlarmListener listener ) { checkIsStarted(); Alarm alarm = removeAlarm( listener ); if (alarm != null) { dequeue( alarm ); notifyWorker( "remove" ); } }
160996_9
public synchronized void remove( AlarmListener listener ) { checkIsStarted(); Alarm alarm = removeAlarm( listener ); if (alarm != null) { dequeue( alarm ); notifyWorker( "remove" ); } }
160999_0
public String getLeaderHostName() throws KeeperException, InterruptedException { List<LeaderOffer> leaderOffers = toLeaderOffers(zooKeeper.getChildren(rootNodeName, false)); if (leaderOffers.size() > 0) { return leaderOffers.get(0).getHostName(); } return null; }
160999_1
public byte[] remove() throws NoSuchElementException, KeeperException, InterruptedException { Map<Long, String> orderedChildren; // Same as for element. Should refactor this. while (true) { try { orderedChildren = orderedChildren(null); } catch (KeeperException.NoNodeException e) { throw new NoSuchElementException(); } if (orderedChildren.size() == 0) { throw new NoSuchElementException(); } for (String headNode : orderedChildren.values()) { String path = dir + "/" + headNode; try { byte[] data = zookeeper.getData(path, false, null); zookeeper.delete(path, -1); return data; } catch (KeeperException.NoNodeException e) { // Another client deleted the node first. } } } }
160999_2
public CircularBlockingQueue(int queueSize) { this.queue = new ArrayDeque<>(queueSize); this.maxSize = queueSize; this.lock = new ReentrantLock(); this.notEmpty = this.lock.newCondition(); this.droppedCount = 0L; }
160999_3
public static String validateFileInput(String filePath) { File file = new File(filePath); if (!file.exists()) { return "File '" + file.getAbsolutePath() + "' does not exist."; } if (!file.canRead()) { return "Read permission is denied on the file '" + file.getAbsolutePath() + "'"; } if (file.isDirectory()) { return "'" + file.getAbsolutePath() + "' is a direcory. it must be a file."; } return null; }
160999_4
public static String validateFileInput(String filePath) { File file = new File(filePath); if (!file.exists()) { return "File '" + file.getAbsolutePath() + "' does not exist."; } if (!file.canRead()) { return "Read permission is denied on the file '" + file.getAbsolutePath() + "'"; } if (file.isDirectory()) { return "'" + file.getAbsolutePath() + "' is a direcory. it must be a file."; } return null; }
160999_5
public static String validateFileInput(String filePath) { File file = new File(filePath); if (!file.exists()) { return "File '" + file.getAbsolutePath() + "' does not exist."; } if (!file.canRead()) { return "Read permission is denied on the file '" + file.getAbsolutePath() + "'"; } if (file.isDirectory()) { return "'" + file.getAbsolutePath() + "' is a direcory. it must be a file."; } return null; }
160999_6
public static String validateFileInput(String filePath) { File file = new File(filePath); if (!file.exists()) { return "File '" + file.getAbsolutePath() + "' does not exist."; } if (!file.canRead()) { return "Read permission is denied on the file '" + file.getAbsolutePath() + "'"; } if (file.isDirectory()) { return "'" + file.getAbsolutePath() + "' is a direcory. it must be a file."; } return null; }
160999_7
public static Date elapsedTimeToDate(long elapsedTime) { long wallTime = currentWallTime() + elapsedTime - currentElapsedTime(); return new Date(wallTime); }
160999_8
public static String formatInetAddr(InetSocketAddress addr) { InetAddress ia = addr.getAddress(); if (ia == null) { return String.format("%s:%s", addr.getHostString(), addr.getPort()); } if (ia instanceof Inet6Address) { return String.format("[%s]:%s", ia.getHostAddress(), addr.getPort()); } else { return String.format("%s:%s", ia.getHostAddress(), addr.getPort()); } }
160999_9
public static String formatInetAddr(InetSocketAddress addr) { InetAddress ia = addr.getAddress(); if (ia == null) { return String.format("%s:%s", addr.getHostString(), addr.getPort()); } if (ia instanceof Inet6Address) { return String.format("[%s]:%s", ia.getHostAddress(), addr.getPort()); } else { return String.format("%s:%s", ia.getHostAddress(), addr.getPort()); } }
161005_0
static org.apache.wiki.search.QueryItem oldQueryItemfrom( final QueryItem item ) { final org.apache.wiki.search.QueryItem qi = new org.apache.wiki.search.QueryItem(); qi.type = item.type; qi.word = item.word; return qi; }
161005_1
static SearchResult newSearchResultFrom( final org.apache.wiki.search.SearchResult result ) { return new SearchResult() { /** {@inheritDoc} */ @Override public Page getPage() { return result.getPage(); } /** {@inheritDoc} */ @Override public int getScore() { return result.getScore(); } /** {@inheritDoc} */ @Override public String[] getContexts() { return result.getContexts(); } }; }
161005_2
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_3
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_4
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_5
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_6
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_7
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_8
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161005_9
public static boolean isNewerOrEqual( final String version ) throws IllegalArgumentException { if( version == null ) { return true; } final String[] versionComponents = StringUtils.split( version, VERSION_SEPARATORS ); final int reqVersion = versionComponents.length > 0 ? Integer.parseInt( versionComponents[0] ) : Release.VERSION; final int reqRevision = versionComponents.length > 1 ? Integer.parseInt( versionComponents[1] ) : Release.REVISION; final int reqMinorRevision = versionComponents.length > 2 ? Integer.parseInt( versionComponents[2] ) : Release.MINORREVISION; if( VERSION == reqVersion ) { if( REVISION == reqRevision ) { if( MINORREVISION == reqMinorRevision ) { return true; } return MINORREVISION > reqMinorRevision; } return REVISION > reqRevision; } return VERSION > reqVersion; }
161180_0
public static final byte[] toBytes(int i){ if(i < INT_N_65535 || i > INT_P_65535) { return Integer.toString(i).getBytes(); } final int absi = Math.abs(i); final byte[] cachedData = i2b_65535[absi]; final byte[] data; if(cachedData == null) { data = Integer.toString(absi).getBytes(); i2b_65535[absi] = data; } else { data = cachedData; } return i >= 0 ? data : getNegativeNumberBytes(data); }
168535_0
@Override protected void onMessage(String argChannel, String argSender, String argLogin, String argHostname, String argMessage) { debug("onMessage: ", "argChannel = " + argChannel, "argSender = " + argSender, "argLogin = " + argLogin, "argHostname = " + argHostname, "argMessage = " + argMessage); batchMessages(format(argSender, argMessage)); }
168535_1
public Entry getNext() { for (Entry entry : entryDao.readAll()) { if (entry.getId() > current.getId()) { return entry; } } return null; }
168535_2
public Entry getPrevious() { Entry previous = null; for (Entry entry : entryDao.readAll()) { if (entry.getId().equals(current.getId()) && previous != null) { return previous; } previous = entry; } return null; }
168535_3
@Get public void load() { entries = entryDao.readAll(); }
168535_4
@Post public String save() { newEntry.setDate(new Date()); Integer id = entryDao.save(newEntry); return String.format("/sample/guestbook/%1$s", id); }
168535_5
@Get public void load(@Named("id") String argId) { entry = entryDao.read(Integer.valueOf(argId)); }
168535_6
@Post public Guestbook delete(@Named("id") String argId) { load(argId); entryDao.delete(entry); return new Guestbook(entryDao); }
169928_0
public List<Program> parse(String programsInCells) { List<Program> result = new LinkedList<Program>(); String programs = buildSingleStringFromCells(programsInCells); int index = 0; while ((index = startIndexOfNextProgram(index, programs)) < programs.length()) { String nextProgramName = calculateNextProgramName(index, programs); index += addNextProgram(nextProgramName, index, result); } return result; }
169928_1
public String CreateWeeklyProgramNamedOnChannelStartingOnAtLengthEpisodes( String programName, int channel, String startDate, String startTime, int lengthInMinutes, int episodes) throws ParseException { generateManyPrograms(programName, channel, startDate, startTime, lengthInMinutes, episodes, 7); return addProgramsToSchedule.lastId(); }
169928_2
public List<Program> parse(List<String> cells) { int channel = Integer.parseInt(cells.get(0)); cells.remove(0); parser.setChannel(channel); return parser.parse(rowAsString(cells)); }
169928_3
public int sizeOfToDoList() { return toDoList.size(); }
175376_0
public static Int Int(int value) { return value >= -2 && value < 1000 ? INTS[value + 2] : new Int(value); }
175376_1
public static Int Int(int value) { return value >= -2 && value < 1000 ? INTS[value + 2] : new Int(value); }
175376_2
public static Int Int(int value) { return value >= -2 && value < 1000 ? INTS[value + 2] : new Int(value); }
175376_3
Expr parseYieldExpr() { return new Expr.Yield(parseOptionalTestList()); }
184604_0
public static int count(String text) { return text.length(); }
184604_1
public Paging() { }
200121_0
public String tag() { return tag; }
200121_1
public CValue value() { return value; }
200121_2
public String tag() { return tag; }
200121_3
public String toString() { return "ConfigurationValue{" + "tag='" + tag + '\'' + ", value='" + value + '\'' + '}'; }
200121_4
@Override public boolean exists() { InputStream is = getInputStream(); boolean result = is != null; try{ if (is != null) { is.close(); } } catch (Exception e) { // Do not care } return result; }
200121_5
@Override public boolean exists() { return new File(extractFileNameFromFileResource(path)).exists(); }
200121_6
@Override public InputStream getInputStream() { try { URL url = new URL(path); return url.openStream(); } catch (MalformedURLException ex) { throw new ConstrettoException("Could not load URL. Path tried: [" + path + "]", ex); } catch (IOException e) { throw new ConstrettoException("Woot", e); } }
200121_7
@Override public InputStream getInputStream() { try { URL url = new URL(path); return url.openStream(); } catch (MalformedURLException ex) { throw new ConstrettoException("Could not load URL. Path tried: [" + path + "]", ex); } catch (IOException e) { throw new ConstrettoException("Woot", e); } }
200121_8
@Override public boolean exists() { try { HttpURLConnection.setFollowRedirects(true); HttpURLConnection con = (HttpURLConnection) new URL(path).openConnection(); con.setRequestMethod("HEAD"); int responseCode = con.getResponseCode(); return (responseCode == HttpURLConnection.HTTP_OK); } catch (Exception e) { return false; } }
200121_9
@Override public boolean exists() { try { HttpURLConnection.setFollowRedirects(true); HttpURLConnection con = (HttpURLConnection) new URL(path).openConnection(); con.setRequestMethod("HEAD"); int responseCode = con.getResponseCode(); return (responseCode == HttpURLConnection.HTTP_OK); } catch (Exception e) { return false; } }
206318_0
@Override public Configuration getChild(String key) { NodeList nl = element.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) { Node n = nl.item(i); if (n.getNodeName().equals(key)) { return new DefaultConfiguration((Element) n); } } return NullConfiguration.INSTANCE; }
206318_1
@Override public Configuration[] getChildren(String key) { ArrayList<Configuration> result = new ArrayList<>(1); NodeList nl = element.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) { Node n = nl.item(i); if (n.getNodeName().equals(key)) { result.add(new DefaultConfiguration((Element) n)); } } return result.toArray(new Configuration[0]); }
206318_2
public String getFilename() { return filename; }
206318_3
@Override protected void copySF(byte[] data, byte type, byte category) { super.copySF(data, type, category); byte[] nameData = getNameBytes(); System.arraycopy(nameData, 0, data, 9, nameData.length); }
206318_4
protected void copySF(byte[] data, byte type, byte category) { copySF(data, SF_CLASS, type, category); }
206318_5
protected void copySF(byte[] data, byte type, byte category) { copySF(data, SF_CLASS, type, category); }
206318_6
protected <S extends Streamable> void writeObjects(Collection<S> objects, OutputStream os) throws IOException { if (objects != null) { Iterator<S> it = objects.iterator(); while (it.hasNext()) { Streamable s = it.next(); s.writeToStream(os); it.remove(); // once written, immediately remove the object } } }
206318_7
protected static String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; }
206318_8
protected static void writeChunksToStream(byte[] data, byte[] dataHeader, int lengthOffset, int maxChunkLength, OutputStream os) throws IOException { int dataLength = data.length; int numFullChunks = dataLength / maxChunkLength; int lastChunkLength = dataLength % maxChunkLength; int headerLen = dataHeader.length - lengthOffset; // length field is just before data so do not include in data length if (headerLen == 2) { headerLen = 0; } byte[] len; int off = 0; if (numFullChunks > 0) { // write out full data chunks len = BinaryUtils.convert(headerLen + maxChunkLength, 2); dataHeader[lengthOffset] = len[0]; // Length byte 1 dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 for (int i = 0; i < numFullChunks; i++, off += maxChunkLength) { os.write(dataHeader); os.write(data, off, maxChunkLength); } } if (lastChunkLength > 0) { // write last data chunk len = BinaryUtils.convert(headerLen + lastChunkLength, 2); dataHeader[lengthOffset] = len[0]; // Length byte 1 dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 os.write(dataHeader); os.write(data, off, lastChunkLength); } }
206318_9
public void addTriplets(Collection<AbstractTriplet> tripletCollection) { if (tripletCollection != null) { triplets.addAll(tripletCollection); } }