/** * Simply reads a property resource file that contains the version of this * Ninja build. Helps to identify the Ninja version currently running. * * @return The version of Ninja. Eg. "1.6-SNAPSHOT" while developing of "1.6" when released. */ private final String readNinjaVersion() { // location of the properties file String LOCATION_OF_NINJA_BUILTIN_PROPERTIES = "ninja/ninja-builtin.properties"; // and the key inside the properties file. String NINJA_VERSION_PROPERTY_KEY = "ninja.version"; String ninjaVersion; try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(LOCATION_OF_NINJA_BUILTIN_PROPERTIES)){ Properties prop = new Properties(); prop.load(stream); ninjaVersion = prop.getProperty(NINJA_VERSION_PROPERTY_KEY); } catch (Exception e) { //this should not happen. Never. throw new RuntimeErrorException(new Error("Something is wrong with your build. Cannot find resource " + LOCATION_OF_NINJA_BUILTIN_PROPERTIES)); } return ninjaVersion; }
Throwable t = x.getTargetException(); if (t instanceof Error) throw new MBeanException(new RuntimeErrorException((Error) t)); else throw new MBeanException((Exception) t);
public Image(File file) { if (file == null || file.getPath().equals(BLANK_IMAGE)) { image = blankImage; } else { try { image = ImageIO.read(file); } catch (IOException e) { throw new RuntimeErrorException(null, "Could not read image " + file); } } }
public static Image fromData(byte[] data) { InputStream istream = new BufferedInputStream(new ByteArrayInputStream(data)); try { return new Image(ImageIO.read(istream)); } catch (IOException e) { throw new RuntimeErrorException(null, "Could not read image data."); } }
public void deleteStuffFromDb(){ ..... usual code.. if (failedCondition){ throw new RuntimeErrorException(new Error("Couldn't delete")); } }
@Override public void setSolver(MDPSolverInterface solver) { if(!(solver instanceof DeterministicPlanner)){ throw new RuntimeErrorException(new Error("Planner is not a Deterministic Planner")); } this.dp = (DeterministicPlanner) solver; }
@Override public void setSolver(MDPSolverInterface solver){ if(!(solver instanceof QProvider)){ throw new RuntimeErrorException(new Error("Planner is not a QComputablePlanner")); } this.qplanner = (QProvider) solver; }
@Override public void setSolver(MDPSolverInterface solver){ if(!(solver instanceof QProvider)){ throw new RuntimeErrorException(new Error("Planner is not a QComputablePlanner")); } this.qplanner = (QProvider) solver; }
@Override public void setSolver(MDPSolverInterface solver){ if(!(solver instanceof QProvider)){ throw new RuntimeErrorException(new Error("Planner is not a QComputablePlanner")); } this.qplanner = (QProvider) solver; }
@Override public void setSolver(MDPSolverInterface solver) { if(!(solver instanceof QProvider)){ throw new RuntimeErrorException(new Error("Planner is not a QComputablePlanner")); } this.qplanner = (QProvider) solver; }
@Override public void setSolver(MDPSolverInterface solver) { if(!(solver instanceof DeterministicPlanner)){ throw new RuntimeErrorException(new Error("Planner is not a Deterministic Planner")); } this.dp = (DeterministicPlanner) solver; }
@Override public Response makeRequest(Request httpRequest) { Response httpResponse; if (Sets.newHashSet(HEAD, GET, DELETE).contains(httpRequest.httpRequestType)) { httpResponse = makeHeadGetOrDeleteRequest(httpRequest); } else if (Sets.newHashSet(POST, PUT).contains(httpRequest.httpRequestType)) { httpResponse = makePostOrPutRequest(httpRequest); } else { throw new RuntimeErrorException(new Error("Your requested httpRequest.httpRequestType is not supported")); } return httpResponse; }
private void rethrowAsRuntimeMBeanException(Throwable t) { if (t instanceof RuntimeException) throw new RuntimeMBeanException((RuntimeException) t); else if (t instanceof Error) throw new RuntimeErrorException((Error) t); else throw new RuntimeMBeanException(new RuntimeException("Unhandled exception", t)); } }
/** * Samples the output probability distribution. * @return the index of the sampled element */ public int sample(){ if(this.needsUpdate){ this.computeProbs(); } double r = this.rand.nextDouble(); double sum = 0.; for(int i = 0; i < this.probs.length; i++){ sum += this.probs[i]; if(r < sum){ return i; } } throw new RuntimeErrorException(new Error("Error in sample; Boltzmann distribution did not sum to 1")); }
private void rethrowAsRuntimeMBeanException(Throwable t) { if (t instanceof RuntimeException) throw new RuntimeMBeanException((RuntimeException) t); else if (t instanceof Error) throw new RuntimeErrorException((Error) t); else throw new RuntimeMBeanException(new RuntimeException("Unhandled exception", t)); } }
private void rethrowAsMBeanException(Throwable t) throws MBeanException { if (t instanceof RuntimeException) throw new RuntimeMBeanException((RuntimeException) t); else if (t instanceof Error) throw new RuntimeErrorException((Error) t); else throw new MBeanException((Exception) t); }
private void rethrowAsMBeanException(Throwable t) throws MBeanException { if (t instanceof RuntimeException) throw new RuntimeMBeanException((RuntimeException) t); else if (t instanceof Error) throw new RuntimeErrorException((Error) t); else throw new MBeanException((Exception) t); }
protected Object invokeImpl(MBeanMetaData metadata, String method, String[] signature, Object[] args) throws ReflectionException, MBeanException, IllegalArgumentException { Method m = getStandardManagementMethod(metadata, method, signature); try { return m.invoke(metadata.mbean, args); } catch (IllegalAccessException x) { throw new ReflectionException(x); } catch (InvocationTargetException x) { Throwable t = x.getTargetException(); if (t instanceof Error) throw new RuntimeErrorException((Error)t); if (t instanceof JMRuntimeException) throw (JMRuntimeException)t; if (t instanceof RuntimeException) throw new RuntimeMBeanException((RuntimeException)t); throw new MBeanException((Exception)t); } }
/** * Returns the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object. * is stored, then it is created and has its Q-value initialize using this objects {@link burlap.behavior.valuefunction.QFunction} data member. * @param s the hashed state for which to get the {@link QLearningStateNode} object * @return the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object. */ protected QLearningStateNode getStateNode(HashableState s){ QLearningStateNode node = qFunction.get(s); if(node == null){ node = new QLearningStateNode(s); List<Action> gas = this.applicableActions(s.s()); if(gas.isEmpty()){ gas = this.applicableActions(s.s()); throw new RuntimeErrorException(new Error("No possible actions in this state, cannot continue Q-learning")); } for(Action ga : gas){ node.addQValue(ga, qInitFunction.qValue(s.s(), ga)); } qFunction.put(s, node); } return node; }
public Object getAttribute(MBeanMetaData metadata, String attribute) throws MBeanException, AttributeNotFoundException, ReflectionException { if (metadata.dynamic) { try { return ((DynamicMBean)metadata.mbean).getAttribute(attribute); } catch (JMRuntimeException x) { throw x; } catch (RuntimeException x) { throw new RuntimeMBeanException(x); } catch (Error x) { throw new RuntimeErrorException(x); } } else { return metadata.invoker.getAttribute(metadata, attribute); } }