public boolean getBoolean(String key) { try { return configuration.getBoolean(key); } catch (NoSuchElementException e) { log.info("Return 'false' for '{}' because of '{}'", key , e.toString()); return false; } }
public int getInt(String key) { try { return configuration.getInt(key); } catch (NoSuchElementException e) { log.info("Return '0' for '{}' because of '{}'", key , e.toString()); return 0; } }
private static CompositeData getRow(int idx, Iterator it) { try { for (int i = 0; i < idx; i++) { it.next(); } } catch (NoSuchElementException ex) { throw new IllegalArgumentException( "Index " + idx + " out of range. Ex: " + ex.toString()); } return (CompositeData) it.next(); }
private static CompositeData getRow(int idx, Iterator it) { try { for (int i = 0; i < idx; i++) { it.next(); } } catch (NoSuchElementException ex) { throw new IllegalArgumentException( "Index " + idx + " out of range. Ex: " + ex.toString(),ex); } return (CompositeData) it.next(); }
@Override public String toString() { return super.toString() + " [ " + getFailureDescription() + " ]"; } }
public double getDouble(String key) { try { return configuration.getDouble(key); } catch (NoSuchElementException e) { log.info("Return '0D' for '{}' because of '{}'", key , e.toString()); return 0D; } }
@Override public String toString() { return super.toString() + " [ " + getFailureDescription() + " ]"; } }
public float getFloat(String key) { try { return configuration.getFloat(key); } catch (NoSuchElementException e) { log.info("Return '0F' for '{}' because of '{}'", key , e.toString()); return 0F; } }
/** Returns the root {@Link Fqn} of the this tree * * @return * @throws CacheException */ public Fqn getFqn() throws CacheException { Fqn fqn; try { fqn = cacheTree.firstKey(); } catch (NoSuchElementException e) { throw new CacheException(e.toString()); } return fqn; }
public SyncMsg(String src) throws MalformedSyncMsgException { try { if (src.startsWith("?")) type = T_REQ; else if (src.startsWith(">")) type = T_REG; else if (src.startsWith("<")) type = T_UREG; else if (src.startsWith("O")) type = T_OVERLOAD; else if (src.startsWith("U")) type = T_UNDERLOAD; else type = T_UNKNOWN; StringTokenizer st = new StringTokenizer(src.substring(1), "|", true); registryUID = st.nextToken(); st.nextToken(); serviceID = st.nextToken(); st.nextToken(); providerURI = st.nextToken(); } catch (NoSuchElementException ex) { throw new MalformedSyncMsgException("message " + src + " mal formé : " + ex.toString()); } }
public SyncMsg(String src) throws MalformedSyncMsgException { try { if (src.startsWith("?")) { type = T_REQ; } else if (src.startsWith(">")) { type = T_REG; } else if (src.startsWith("<")) { type = T_UREG; } else if (src.startsWith("O")) { type = T_OVERLOAD; } else if (src.startsWith("U")) { type = T_UNDERLOAD; } else { type = T_UNKNOWN; } StringTokenizer st = new StringTokenizer(src.substring(1), "|", true); registryUID = st.nextToken(); st.nextToken(); serviceID = st.nextToken(); st.nextToken(); providerURI = st.nextToken(); } catch (NoSuchElementException ex) { throw new MalformedSyncMsgException("message " + src + " mal formé : " + ex.toString()); } }
@Override protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return; } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); String userID; String itemID; try { userID = pathComponents.next(); itemID = pathComponents.next(); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } OryxRecommender recommender = getRecommender(); recommender.removePreference(userID, itemID); }
/** Returns the root {@Link Fqn} of the this tree * * @return * @throws CacheException */ public Fqn getFqn() throws CacheException { Fqn fqn; try { fqn = cacheTree.firstKey(); } catch (NoSuchElementException e) { throw new CacheException(e.toString()); } touch(fqn); return fqn; }
/** * Returns the next element of the enumeration. * * <p>If no further elements available a com.sun.star.container.NoSuchElementException * exception will be thrown.</p> * * @return the next element. * @see com.sun.star.container.XEnumeration */ public Object nextElement() throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException, com.sun.star.uno.RuntimeException { if (enumeration == null) throw new com.sun.star.container.NoSuchElementException(); try { return enumeration.next(); } catch (java.util.NoSuchElementException e) { throw new com.sun.star.container.NoSuchElementException(e, e.toString()); } } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return; } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); String userID; try { userID = pathComponents.next(); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } OryxRecommender recommender = getRecommender(); try { output(request, response, recommender.getKnownItemsForUser(userID)); } catch (NotReadyException nre) { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString()); } }
@Override protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return; } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); long userID; long itemID; try { userID = Long.parseLong(pathComponents.next()); itemID = Long.parseLong(pathComponents.next()); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } catch (NumberFormatException nfe) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString()); return; } MyrrixRecommender recommender = getRecommender(); try { recommender.removePreference(userID, itemID); } catch (TasteException te) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString()); getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te); } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return; } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); String userID; List<String> itemIDsList; try { userID = pathComponents.next(); itemIDsList = new ArrayList<>(); while (pathComponents.hasNext()) { itemIDsList.add(pathComponents.next()); } } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } String[] itemIDs = itemIDsList.toArray(new String[itemIDsList.size()]); unescapeSlashHack(itemIDs); OryxRecommender recommender = getRecommender(); try { float[] estimates = recommender.estimatePreferences(userID, itemIDs); output(request, response, estimates); } catch (NotReadyException nre) { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString()); } }
userID = pathComponents.next(); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return;
itemIDsAndValue = RecommendToAnonymousServlet.parseItemValuePairs(pathComponents); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return;
@Test(groups={"Live", "Live-sanity"}) public void testJcloudsCreateWithHardwareIdShortFormWithNoRegion() throws Exception { replaceJcloudsLocation(GCE_PROVIDER); try { obtainMachine(ImmutableMap.of(JcloudsLocation.HARDWARE_ID, N1_STANDARD_1_HARDWARE_ID)); Asserts.shouldHaveFailedPreviously(); } catch (Exception e) { NoSuchElementException nsee = Exceptions.getFirstThrowableOfType(e, NoSuchElementException.class); if (nsee == null || !nsee.toString().contains("hardwareId("+N1_STANDARD_1_HARDWARE_ID+") not found")) { throw e; } } } }