/** * poll a Runnable form {@link #mPool} * * @return Runnable */ private Runnable poll() { synchronized (mPool) { try { return mPool.poll(); } catch (NoSuchElementException e) { e.printStackTrace(); return null; } } }
/** {@inheritDoc} */ @Override public boolean add(E e) { GridArgumentCheck.notNull(e, "e"); if (super.add(e)) { cnt.incrementAndGet(); int c; while ((c = cnt.get()) > max) { // Decrement count. if (cnt.compareAndSet(c, c - 1)) { try { while (!super.remove(first())) { // No-op. } } catch (NoSuchElementException e1) { e1.printStackTrace(); // Should never happen. assert false : "Internal error in grid bounded ordered set."; } } } return true; } return false; }
protected static Point stringToPoint( String value ) { Point pt = null; StringTokenizer tok; if( value != null ) { try { tok = new StringTokenizer( value ); pt = new Point( Integer.parseInt( tok.nextToken() ), Integer.parseInt( tok.nextToken() )); } catch( NoSuchElementException e1 ) { e1.printStackTrace(); } catch( NumberFormatException e2 ) { e2.printStackTrace(); } } return pt; }
protected static Dimension stringToDimension( String value ) { Dimension dim = null; StringTokenizer tok; if( value != null ) { try { tok = new StringTokenizer( value ); dim = new Dimension( Integer.parseInt( tok.nextToken() ), Integer.parseInt( tok.nextToken() )); } catch( NoSuchElementException e1 ) { e1.printStackTrace(); } catch( NumberFormatException e2 ) { e2.printStackTrace(); } } return dim; }
private static Rectangle stringToRectangle( String value ) { Rectangle rect = null; final StringTokenizer tok; if( value != null ) { try { tok = new StringTokenizer( value ); rect = new Rectangle( Integer.parseInt( tok.nextToken() ), Integer.parseInt( tok.nextToken() ), Integer.parseInt( tok.nextToken() ), Integer.parseInt( tok.nextToken() )); } catch( NoSuchElementException e1 ) { e1.printStackTrace(); } catch( NumberFormatException e2 ) { e2.printStackTrace(); } } return rect; }
public CustomPopupHelper(URL url) { super(); xmlFile = null; try { itemBean = CustomPopupItemBean.loadXML(url); item.setText(itemBean.getName()); } catch (NoSuchElementException e) { JOptionPane.showMessageDialog(item, "custom popup item xml has bad format"); e.printStackTrace(); } catch (IOException e) { JOptionPane.showMessageDialog(item, "custom popup item file not found in customPopup/ directory"); e.printStackTrace(); } }
public CustomPopupHelper(File file) { super(); this.xmlFile = file; try { itemBean = CustomPopupItemBean.loadXML(xmlFile); item.setText(itemBean.getName()); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(item, "custom popup item file not found in customPopup/ directory"); e.printStackTrace(); } catch (NoSuchElementException e) { JOptionPane.showMessageDialog(item, "custom popup item xml has bad format"); e.printStackTrace(); } }
public static String take() { String message = null; if (GameModeType.SERVER == mode) { message = getInput("QUERY"); if (message.equals("error")) { message = "exit"; } } else { Scanner input = null; try { input = new Scanner(System.in); message = input.nextLine(); } catch (NoSuchElementException nsee) { nsee.printStackTrace(); } catch (IllegalStateException ise) { ise.printStackTrace(); } } return message; } }
public static Segment unpickle(String value) { Segment seg = new Segment() ; StringTokenizer st = new StringTokenizer(value, SEPARATOR); try { int type = Integer.parseInt(st.nextToken()); seg.start = Integer.parseInt(st.nextToken()); seg.end = Integer.parseInt(st.nextToken()); if (type == COMMAND) { int n = Integer.parseInt(st.nextToken()); String parNames[] = new String[n] ; String parValues[] = new String[n] ; for (int i = 0 ; i < n ; i++) { parNames[i] = st.nextToken(); parValues[i] = st.nextToken(); } seg.parameters = new ArrayDictionary(parNames,parValues) ; } else { seg.commandName = null ; seg.parameters = null ; } } catch (NoSuchElementException ex) { ex.printStackTrace(); } return seg; }
@Override public void map(LongWritable key, Text val, OutputCollector<IntWritable, Text> out, Reporter reporter) throws IOException { String line = val.toString(); StringTokenizer tokenizer = new StringTokenizer(line); try { String vid = tokenizer.nextToken(); if (hashRawVid) { // partition by old vid Object rawId = vidparser.getValue(tokenizer.nextToken()); int hash = rawId.hashCode() % numChunks; if (hash < 0) hash += numChunks; // resolving negative hashcode out.collect(new IntWritable(hash), val); } else { // partition by new vid int hash = Long.valueOf(vid).hashCode() % numChunks; out.collect(new IntWritable(hash), val); } } catch (NoSuchElementException e) { e.printStackTrace(); LOG.error("Error parsing vertex dictionary: " + val.toString()); } }
@Override public void loadItem(String name) throws FileNotFoundException, ParseException { try { customPopupItem = CustomPopupItemBean.loadXML(name + ".xml"); } catch (java.util.NoSuchElementException e) { e.printStackTrace(); throw new ParseException(e.getMessage(), -1); } Data2Panel(); }
@Override public Vertex<VidType, VertexData> parseVertex(String text, FieldParser<VidType> vidparser, FieldParser<VertexData> vdataparser) { StringTokenizer tokenizer = new StringTokenizer(text); try { VidType id = vidparser.getValue(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) { return new Vertex<VidType, VertexData>(id, vdataparser.getValue(tokenizer.nextToken())); } else { return new Vertex<VidType, VertexData>(id, vdataparser.getValue("")); } } catch (NumberFormatException e) { e.printStackTrace(); } catch (NoSuchElementException e) { e.printStackTrace(); } LOG.error("Error in parsing line:" + text); return null; }
@Override public Edge<VidType, EdgeData> parseEdge(String text, FieldParser<VidType> vidparser, FieldParser<EdgeData> edataparser) { StringTokenizer tokenizer = new StringTokenizer(text); try { VidType source = vidparser.getValue(tokenizer.nextToken()); VidType target = vidparser.getValue(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) { return new Edge<VidType, EdgeData>(source, target, edataparser.getValue(tokenizer.nextToken())); } else { return new Edge<VidType, EdgeData>(source, target, edataparser.getValue("")); } } catch (NumberFormatException e) { e.printStackTrace(); } catch (NoSuchElementException e) { e.printStackTrace(); } LOG.error("Error in parsing line:" + text); return null; }
/** {@inheritDoc} */ @Override public boolean add(E e) { GridArgumentCheck.notNull(e, "e"); if (super.add(e)) { cnt.incrementAndGet(); int c; while ((c = cnt.get()) > max) { // Decrement count. if (cnt.compareAndSet(c, c - 1)) { try { while (!super.remove(first())) { // No-op. } } catch (NoSuchElementException e1) { e1.printStackTrace(); // Should never happen. assert false : "Internal error in grid bounded ordered set."; } } } return true; } return false; }
/** {@inheritDoc} */ @Override public boolean add(E e) { GridArgumentCheck.notNull(e, "e"); if (super.add(e)) { cnt.incrementAndGet(); int c; while ((c = cnt.get()) > max) { // Decrement count. if (cnt.compareAndSet(c, c - 1)) { try { while (!super.remove(first())) { // No-op. } } catch (NoSuchElementException e1) { e1.printStackTrace(); // Should never happen. assert false : "Internal error in grid bounded ordered set."; } } } return true; } return false; }
public void processPdu(SnmpRequest request, MOServer server) { initRequestPhase(request); OctetString context = request.getContext(); try { Iterator<SnmpRequest.SnmpSubRequest> it = request.iterator(); while (it.hasNext()) { SubRequest sreq = it.next(); processNextSubRequest(request, server, context, sreq); } } catch (NoSuchElementException nsex) { if (logger.isDebugEnabled()) { nsex.printStackTrace(); } logger.error("SubRequest not found"); request.setErrorStatus(PDU.genErr); } }
public void processPdu(Request request, MOServer server) { initRequestPhase(request); OctetString context = request.getContext(); try { SubRequestIterator it = (SubRequestIterator) request.iterator(); while (it.hasNext()) { SubRequest sreq = it.nextSubRequest(); processNextSubRequest(request, server, context, sreq); } } catch (NoSuchElementException nsex) { if (logger.isDebugEnabled()) { nsex.printStackTrace(); } logger.error("SubRequest not found"); request.setErrorStatus(PDU.genErr); } }
IndexWord initializeFrom(String line) { TokenizerParser tokenizer = new TokenizerParser(line, " "); this.lemma = tokenizer.nextToken().replace('_', ' '); this.pos = POS.lookup(tokenizer.nextToken()); tokenizer.nextToken(); // poly_cnt int p_cnt = tokenizer.nextInt(); ptrTypes = new PointerType[p_cnt]; for (int i = 0; i < p_cnt; i++) { try { ptrTypes[i] = PointerType.parseKey(tokenizer.nextToken()); } catch (java.util.NoSuchElementException exc) { exc.printStackTrace(); } } int senseCount = tokenizer.nextInt(); this.taggedSenseCount = tokenizer.nextInt(); this.synsetOffsets = new long[senseCount]; for (int i = 0; i < senseCount; i++) { synsetOffsets[i] = tokenizer.nextLong(); } return this; }
IndexWord initializeFrom(String line) { TokenizerParser tokenizer = new TokenizerParser(line, " "); this.lemma = tokenizer.nextToken().replace('_', ' '); this.pos = POS.lookup(tokenizer.nextToken()); tokenizer.nextToken(); // poly_cnt int p_cnt = tokenizer.nextInt(); ptrTypes = new PointerType[p_cnt]; for (int i = 0; i < p_cnt; i++) { try { ptrTypes[i] = PointerType.parseKey(tokenizer.nextToken()); } catch (java.util.NoSuchElementException exc) { exc.printStackTrace(); } } int senseCount = tokenizer.nextInt(); this.taggedSenseCount = tokenizer.nextInt(); this.synsetOffsets = new long[senseCount]; for (int i = 0; i < senseCount; i++) { synsetOffsets[i] = tokenizer.nextLong(); } return this; }
@Test public void testCreateDestroySecurityGroup() { try { zone = Iterables.find(client.getZoneClient().listZones(), new Predicate<Zone>() { @Override public boolean apply(Zone arg0) { return arg0.isSecurityGroupsEnabled(); } }); securityGroupsSupported = true; for (SecurityGroup securityGroup : client.getSecurityGroupClient().listSecurityGroups( ListSecurityGroupsOptions.Builder.named(prefix))) { for (IngressRule rule : securityGroup.getIngressRules()) assertTrue(jobComplete.apply(client.getSecurityGroupClient().revokeIngressRule(rule.getId())), rule.toString()); client.getSecurityGroupClient().deleteSecurityGroup(securityGroup.getId()); } group = client.getSecurityGroupClient().createSecurityGroup(prefix); assertEquals(group.getName(), prefix); checkGroup(group); try { client.getSecurityGroupClient().createSecurityGroup(prefix); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { } } catch (NoSuchElementException e) { e.printStackTrace(); } }