id
stringlengths
7
14
text
stringlengths
1
106k
1484463_2
@Override public void handle(final Event event) { try { final ProducerData<String, String> data = new ProducerData<String, String>(event.getEventType(), eventToMessage(event)); producer.send(data); eventsSent.incrementAndGet(); } catch (IOException e) { log.warn(e); e...
1484463_3
public List<HostSamplesForTimestamp> readAll() { final List<HostSamplesForTimestamp> samples = new ArrayList<HostSamplesForTimestamp>(); readAll(true, null, new Function<HostSamplesForTimestamp, Void>() { @Override public Void apply(@Nullable final HostSamplesForTimestamp input) { ...
1484463_4
public synchronized TimelineChunk extractTimelineChunkAndReset(final DateTime startTime, final DateTime endTime, final byte[] timeBytes) { // Extract the chunk final byte[] sampleBytes = getEncodedSamples().getEncodedBytes(); log.debug("Creating TimelineChunk for sampleKindId %d, sampleCount %d", sampleKind...
1484463_5
public synchronized TimelineChunk extractTimelineChunkAndReset(final DateTime startTime, final DateTime endTime, final byte[] timeBytes) { // Extract the chunk final byte[] sampleBytes = getEncodedSamples().getEncodedBytes(); log.debug("Creating TimelineChunk for sampleKindId %d, sampleCount %d", sampleKind...
1484463_6
public synchronized TimelineChunk extractTimelineChunkAndReset(final DateTime startTime, final DateTime endTime, final byte[] timeBytes) { // Extract the chunk final byte[] sampleBytes = getEncodedSamples().getEncodedBytes(); log.debug("Creating TimelineChunk for sampleKindId %d, sampleCount %d", sampleKind...
1484463_7
public void addSampleKind(final String sampleKind) { sampleKinds.add(sampleKind); }
1484463_8
@Override public Object process(Object value) { Long time = System.currentTimeMillis(); if (this.lastValue == null) { this.lastUpdate = time; this.lastValue = value; return null; // no value at this time } if (!(value instanceof Number)) { throw new IllegalArgumentException(String.format("Rate r...
1484463_9
@Override public Object process(Object value) { Long time = System.currentTimeMillis(); if (this.lastValue == null) { this.lastUpdate = time; this.lastValue = value; return null; // no value at this time } if (!(value instanceof Number)) { throw new IllegalArgumentException(String.format("Rate r...
1493029_0
public void loadResource(URL url) { try { // Is Local loadResource( new File( url.toURI() ), "" ); } catch (IllegalArgumentException iae) { // Is Remote loadRemoteResource( url ); } catch (URISyntaxException e) { throw new JclException( "URISyntaxException", e ); ...
1493029_1
@SuppressWarnings("rawtypes") public Class loadClass(String className, boolean resolveIt) { Class result; try { result = delegate.loadClass(className, resolveIt); } catch (ClassNotFoundException e) { return null; } return result; }
149511_10
public boolean isUnderRevisionControl() { return true; }
149511_11
public boolean isCheckedIn() { return true; }
149511_12
public boolean isCheckedOut() { return true; }
1495584_0
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_1
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_2
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_3
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_4
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_5
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_6
@Override public String getClassSimpleName() { return constructor.getDeclaringClass().getSimpleName(); }
1495584_7
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_8
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1495584_9
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); /* * Due to constraints on the constructor, cause can only be an * unchecked exception. */ if (caus...
1502367_0
public ConstructedMessage getConstructedMessage(int messageId) { return keyValue.get("M-" + messageId); }
1502367_1
public static XMLModel getProtocolConfiguration(String protocolLocation) throws JAXBException, IOException { JAXBContext context = JAXBContext.newInstance(XMLModel.class); Unmarshaller um = context.createUnmarshaller(); return (XMLModel) um.unmarshal(new ClassPathResource(protocolLocation).getInputStream()); }
1502367_2
public void put(Request request) throws InterruptedException { Node node = new Node(executor, new NodeCallable(handler, request)); queue.put(node); }
1502367_3
public void loadDBSchema(DataSource dataSource, String schemaName) throws DataAccessException, FileNotFoundException { JdbcTemplate template = new JdbcTemplate(dataSource); InputStream is = null; try { is = new ClassPathResource(schemaName).getInputStream(); contents = IOUtils.toString(is); } catch (IOExcepti...
1502367_4
public void sendEmail(SendBoxInfo sendBoxInfo, EmailContent sendContent, String[] to) throws MessagingException, MailException { JavaMailSenderImpl senderImpl = new JavaMailSenderImpl(); // 设定mail server senderImpl.setHost(sendBoxInfo.getHost()); senderImpl.setPort(sendBoxInfo.getPort()); senderImpl.setUsername(...
1502367_5
public void batchInsertEmailOutbox(List<Object[]> batchArgs) { super.batchUpdate(INSERT_EMAIL_OUTBOX, batchArgs); }
1502367_6
public void batchInsertEmailInbox(List<Object[]> batchArgs) { super.batchUpdate(INSERT_EMAIL_INBOX, batchArgs); }
1502367_7
public List<EmailInbox> queryInboxToSend(int amount) { return pageByProperty(Collections.singletonMap("state", (Object) EmailInbox.STATE_TO_SEND), 0, amount, "id", false); }
1502367_8
public Software querySoftware(String softwareName) throws DataAccessException { return (Software) getSqlSession().selectOne(STMT_QUERY_SOFTWARE_BY_NAME, softwareName); }
1502367_9
public int insertSoftware(Software software) throws DataAccessException { return getSqlSession().insert(STMT_INSERT_SOFTWARE, software); }
1511246_0
public static Object getDefaultValue(Class<?> c) { if (!c.isPrimitive()) { return null; } if (c == boolean.class) { return false; } else if (c == byte.class) { return (byte) 0; } else if (c == char.class) { return (char) 0; } else if (c == short.class) { r...
1511246_1
public static Class<?> getNonPrimitiveClass(Class<?> c) { if (!c.isPrimitive()) { return c; } else if (c == boolean.class) { return Boolean.class; } else if (c == byte.class) { return Byte.class; } else if (c == char.class) { return Character.class; } else if (c == do...
1511246_2
public static String getPackageName(Class<?> c) { Package p = c.getPackage(); if (p != null) { return p.getName(); } if (c.isPrimitive()) { return ""; } String s = c.getName(); int lastDot = s.lastIndexOf('.'); if (lastDot < 0) { return ""; } return s.subs...
1511246_3
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1511246_4
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1511246_5
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1511246_6
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1511246_7
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1511246_8
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1511246_9
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?> pc = getClassProxy(c); Constructor<?> cons; try { cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class }); return (T) cons.newInstance(new ...
1516026_0
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_1
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_2
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_3
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_4
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_5
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_6
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_7
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_8
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1516026_9
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { Date...
1520524_0
public TimeManager() { dateFormat = new SimpleDateFormat("HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); startTime = System.currentTimeMillis(); }
1520524_1
public synchronized double getElapsedTimeInHours() { double currentTime = System.currentTimeMillis(); return (currentTime - startTime) / (60 * 60 * 1000); }
1520524_2
public synchronized double getElapsedTimeInMinutes() { double currentTime = System.currentTimeMillis(); return (currentTime - startTime) / (60 * 1000); }
1520524_3
public synchronized double getElapsedTimeInSeconds() { double currentTime = System.currentTimeMillis(); return ((currentTime - startTime) / 1000); }
1520524_4
public synchronized double getElapsedTimeInMilliSeconds() { double currentTime = System.currentTimeMillis(); return (currentTime - startTime); }
1520524_5
public synchronized static BondEnergies getInstance() throws CDKException { if (null == instance) { instance = new BondEnergies(); } return instance; }
1520524_6
public synchronized int getEnergies(IAtom sourceAtom, IAtom targetAtom, Order bondOrder) { String sourceAtomSymbol = null; if (!(sourceAtom instanceof IQueryAtom)) { sourceAtomSymbol = sourceAtom.getSymbol(); } else { return 0; } String targetAtomSymbol = targetAtom.getSymbol(); ...
1520524_7
public synchronized String getSymbolFirstAtom() { return symbol1; }
1520524_8
public synchronized String getSymbolSecondAtom() { return symbol2; }
1520524_9
public synchronized IBond.Order getBondOrder() { return bondOrder; }
152134_10
@SuppressWarnings("unchecked") public List<Person> findAll() { return getJdbcTemplate().query("SELECT * FROM employee", new Object[0], new PersonRowMapper()); }
152134_11
public static byte[] readIntoByteArray(InputStream in) throws IOException { ByteArrayOutputStream content = new ByteArrayOutputStream(); pipe(in, content); return content.toByteArray(); }
152134_12
public static String readIntoString(Reader reader) throws IOException { StringWriter writer = new StringWriter(); pipe(reader, writer); return writer.toString(); }
152134_13
public static void pipe(InputStream source, OutputStream destination) throws IOException { int r = -1; byte[] buffer = new byte[8096]; while ((r = source.read(buffer, 0, buffer.length)) != -1) { destination.write(buffer, 0, r); } }
152134_14
public static void pipe(InputStream source, OutputStream destination) throws IOException { int r = -1; byte[] buffer = new byte[8096]; while ((r = source.read(buffer, 0, buffer.length)) != -1) { destination.write(buffer, 0, r); } }
152134_15
public void writeFile(String path, byte[] content) throws IOException { writeFile(path, new ByteArrayInputStream(content)); }
152134_16
public void writeFile(String path, byte[] content) throws IOException { writeFile(path, new ByteArrayInputStream(content)); }
152134_17
public double add(double left, double right) { addToHistory(left, '+', right); return left + right; }
152134_18
public double subtract(double left, double right) { addToHistory(left, '-', right); return left - right; }
152134_19
public double multiply(double left, double right) { addToHistory(left, '*', right); return left * right; }
152134_20
public double divide(double left, double right) { addToHistory(left, '/', right); if (right == 0.0d) { throw new IllegalArgumentException( "Can't divide with zero"); } return left / right; }
152134_21
public void buyTicket() throws InterruptedException { tickets.acquire(); }
152134_22
public int add(int a, int b) { notifyJmsQueue(a, b); return a + b; }
152134_23
public int add(int a, int b) { notifyJmsQueue(a, b); return a + b; }
152134_24
public Price discountedPrice(Product product, Account account) { try { DiscountService discounts = getDiscountService(); int discount = discounts.getDiscountPercentage(account); float discountMultiplier = ((100 - discount) / 100.0f); return new Price((int) (product.getPrice() * disco...
152134_25
public Price discountedPrice(Product product, Account account) { try { DiscountService discounts = getDiscountService(); int discount = discounts.getDiscountPercentage(account); float discountMultiplier = ((100 - discount) / 100.0f); return new Price((int) (product.getPrice() * disco...
152134_26
public Price discountedPrice(Product product, Account account) { try { DiscountService discounts = getDiscountService(); int discount = discounts.getDiscountPercentage(account); float discountMultiplier = ((100 - discount) / 100.0f); return new Price((int) (product.getPrice() * disco...
152134_27
public void onMessage(Message message) { try { ObjectMessage searchRequest = (ObjectMessage) message; String[] keywords = (String[]) searchRequest.getObject(); String[] results = searchService.search(keywords); QueueConnection connection = connectionFactory .createQue...
152134_28
public User findByUsername(String username) { Query query = em.createNamedQuery("findUserByUsername"); query.setParameter("username", username); return (User) query.getSingleResult(); }
152134_29
@Override public Class<? extends Page> getHomePage() { return MyHomePage.class; }
152134_30
public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"...
152134_31
public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"...
152134_32
public List<String> parse(String template) { List<String> segments = new ArrayList<String>(); int index = collectSegments(template, segments, 0); addTail(segments, template, index); return segments; }
152134_33
public List<String> parse(String template) { List<String> segments = new ArrayList<String>(); int index = collectSegments(template, segments, 0); addTail(segments, template, index); return segments; }
152134_34
public List<String> parse(String template) { List<String> segments = new ArrayList<String>(); int index = collectSegments(template, segments, 0); addTail(segments, template, index); return segments; }
152134_35
public List<Segment> parseSegments(String template) { List<Segment> segments = new ArrayList<Segment>(); List<String> strings = parse(template); for (String s : strings) { if (isVariable(s)) { String name = s.substring(2, s.length() - 1); segments.add(new Variable(name)); ...
152134_36
public void set(String name, String value) { this.variables.put(name, value); }
152134_37
public void set(String name, String value) { this.variables.put(name, value); }
152134_38
public String evaluate() { TemplateParse p = new TemplateParse(); List<Segment> segments = p.parseSegments(templateText); return concatenate(segments); }
152134_39
public String evaluate() { TemplateParse p = new TemplateParse(); List<Segment> segments = p.parseSegments(templateText); return concatenate(segments); }
152134_40
public Prompt join(final String nickname, Client user) { clients.put(nickname, user); return new Prompt() { @Override public void say(String message) { deliverMessage(nickname, message); } }; }
152134_41
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (getAuthenticator().isValidLogin(user, pass)) { req...
152134_42
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (getAuthenticator().isValidLogin(user, pass)) { req...
152134_43
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"...
152134_44
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"...
152134_45
public void parse (Reader input, Writer output) throws Exception { this.input = input; this.output = output; int i; while (-1 != (i = input.read())) { this.c = (char)i; this.cnt++; switch (this.state) { case IN_TAG: this.handleInTag(); break; default: this.handleUnknown(); break; } } }
152134_46
public void parse (Reader input, Writer output) throws Exception { this.input = input; this.output = output; int i; while (-1 != (i = input.read())) { this.c = (char)i; this.cnt++; switch (this.state) { case IN_TAG: this.handleInTag(); break; default: this.handleUnknown(); break; } } }