/** * Loads the properties stored in the given file. This method does nothing if * the file does not exist or is unreadable. Appends the contents of the loaded * properties to the already stored contents. * * @param in the input stream used to read the properties. */ public void load(final InputStream in) { if (in == null) { throw new NullPointerException(); } try { final BufferedInputStream bin = new BufferedInputStream(in); final Properties p = new Properties(); p.load(bin); this.getConfiguration().putAll(p); bin.close(); } catch (IOException ioe) { Log.warn("Unable to read configuration", ioe); } }
/** * Loads the properties stored in the given file. This method does nothing if * the file does not exist or is unreadable. Appends the contents of the loaded * properties to the already stored contents. * * @param in the input stream used to read the properties. */ public void load(final InputStream in) { if (in == null) { throw new NullPointerException(); } try { final BufferedInputStream bin = new BufferedInputStream(in); final Properties p = new Properties(); p.load(bin); this.getConfiguration().putAll(p); bin.close(); } catch (IOException ioe) { Log.warn("Unable to read configuration", ioe); } }
/** * Loads the properties stored in the given file. This method does nothing if * the file does not exist or is unreadable. Appends the contents of the loaded * properties to the already stored contents. * * @param in the input stream used to read the properties. */ public void load(final InputStream in) { if (in == null) { throw new NullPointerException(); } try { final BufferedInputStream bin = new BufferedInputStream(in); final Properties p = new Properties(); p.load(bin); this.getConfiguration().putAll(p); bin.close(); } catch (IOException ioe) { Log.warn("Unable to read configuration", ioe); } }
/** * Loads a class by its fully qualified name. * * @param name the class name. * * @return The class (or <code>null</code> if there was a problem loading the class). */ protected Class loadClass(final String name) { try { return ObjectUtilities.getClassLoader(JavaSourceCollector.class).loadClass(name); } catch (Exception e) { Log.warn (new Log.SimpleMessage("Do not process: Failed to load class:", name)); return null; } }
/** * Loads the given class, and ignores all exceptions which may occur * during the loading. If the class was invalid, null is returned instead. * * @param className the name of the class to be loaded. * @return the class or null. */ protected Class loadClass(final String className) { if (className == null) { return null; } if (className.startsWith("::")) { return BasicTypeSupport.getClassRepresentation(className); } try { return ObjectUtilities.getClassLoader(getClass()).loadClass(className); } catch (Exception e) { // ignore buggy classes for now .. Log.warn("Unable to load class", e); return null; } }
/** * Starts a object definition. The object definition collects all properties of * an bean-class and defines, which constructor should be used when creating the * class. * * @param className the class name of the defined object * @param register the (optional) register name, to lookup and reference the object later. * @param ignore ignore? * * @return true, if the definition was accepted, false otherwise. * @throws ObjectDescriptionException if an unexpected error occured. */ protected boolean startObjectDefinition(final String className, final String register, final boolean ignore) throws ObjectDescriptionException { if (ignore) { return false; } this.target = loadClass(className); if (this.target == null) { Log.warn(new Log.SimpleMessage("Failed to load class ", className)); return false; } this.registerName = register; this.propertyDefinition = new ArrayList(); this.attributeDefinition = new ArrayList(); this.constructorDefinition = new ArrayList(); this.lookupDefinitions = new ArrayList(); this.orderedNames = new ArrayList(); return true; }
/** * Creates an object based on the description. * * @return The object. */ public Object createObject() { try { final Collection l = (Collection) getObjectClass().newInstance(); int counter = 0; while (getParameterDefinition(String.valueOf(counter)) != null) { final Object value = getParameter(String.valueOf(counter)); if (value == null) { break; } l.add(value); counter += 1; } return l; } catch (Exception ie) { Log.warn("Unable to instantiate Object", ie); return null; } }
/** * Creates an object based on this description. * * @return The object. */ public Object createObject() { final String o = (String) getParameter("value"); final String baseURL = getConfig().getConfigProperty(Parser.CONTENTBASE_KEY); try { try { final URL bURL = new URL(baseURL); return new URL(bURL, o); } catch (Exception e) { Log.warn("BaseURL is invalid: ", e); } return new URL(o); } catch (Exception e) { return null; } }
/** * Returns a URL pointing to a resource located in the classpath. The * resource is looked up using the given key. * <p/> * Example: The load a file named 'logo.gif' which is stored in a java * package named 'org.jfree.resources': * <pre> * mainmenu.logo=org/jfree/resources/logo.gif * </pre> * The URL for that file can be queried with: <code>getResource("mainmenu.logo");</code>. * * @param key the key for the resource * @return the resource URL */ public URL getResourceURL(final String key) { final String name = getString(key); final URL in = ObjectUtilities.getResource(name, ResourceBundleSupport.class); if (in == null) { Log.warn("Unable to find file in the class path: " + name + "; key=" + key); } return in; }
/** * Returns a URL pointing to a resource located in the classpath. The * resource is looked up using the given key. * <p> * Example: The load a file named 'logo.gif' which is stored in a java * package named 'org.jfree.resources':</p> * <pre> * mainmenu.logo=org/jfree/resources/logo.gif * </pre> * The URL for that file can be queried with: <code>getResource("mainmenu.logo");</code>. * * @param key the key for the resource * @return the resource URL */ public URL getResourceURL(final String key) { final String name = getString(key); final URL in = ObjectUtilities.getResource(name, ResourceBundleSupport.class); if (in == null) { Log.warn("Unable to find file in the class path: " + name + "; key=" + key); } return in; }
/** * Gets a file resource from a project * * @param file * @return */ protected static CSharpFile from(Project project, File file, boolean unitTest) { if (unitTest) { Log.error("test " + file); } File directory = file.getParentFile(); CSharpFolder folder = CSharpFolder.fromDirectory(project, directory); if (folder == null) { Log.warn("Could not find the folder for directory : " + directory + " in project " + project); } return new CSharpFile(folder, file, unitTest); }
public static void put(@Nonnull User user, @Nonnull String accessToken) { Log.debug("Populating the cache for username: " + user.getId()); try { user.addProperty(new GithubAccessTokenProperty(accessToken)); } catch (IOException e) { Log.warn("Received an exception when trying to add the GitHub access token to the user: " + user.getId(), e); } } }
/** * Returns a URL pointing to a resource located in the classpath. The * resource is looked up using the given key. * <p/> * Example: The load a file named 'logo.gif' which is stored in a java * package named 'org.jfree.resources': * <pre> * mainmenu.logo=org/jfree/resources/logo.gif * </pre> * The URL for that file can be queried with: <code>getResource("mainmenu.logo");</code>. * * @param key the key for the resource * @return the resource URL */ public URL getResourceURL(final String key) { final String name = getString(key); final URL in = ObjectUtilities.getResource(name, ResourceBundleSupport.class); if (in == null) { Log.warn("Unable to find file in the class path: " + name + "; key=" + key); } return in; }
protected static int getMaximumBuilds( Chartable chartable ) { if( chartable == null ) return 0; CoberturaBuildAction action = chartable.getOwner().getAction(CoberturaBuildAction.class); if( action != null ) { return action.getMaxNumberOfBuilds(); } else { Log.warn( "Couldn't find CoberturaPublisher to decide the maximum number of builds to be graphed" ); return 0; } }
protected static boolean isZoomCoverageChart( Chartable chartable ) { if( chartable == null ) return false; CoberturaBuildAction action = chartable.getOwner().getAction(CoberturaBuildAction.class); boolean zoomCoverageChart = false; if( action != null ) { return action.getZoomCoverageChart(); } else { Log.warn( "Couldn't find CoberturaPublisher to decide if the graph should be zoomed" ); return false; } }
private List<Object> getDBObjects(Session session, HistProp prop) { List<Object> ret = new ArrayList<>(); EntityMetadata emd = PfEmgrFactory.get().getMetadataRepository().findEntityMetadata(prop.getType()); if (emd == null) { ret.add(prop.getValue()); return ret; } String[] sa = StringUtils.split(prop.getValue(), ", "); if (sa == null || sa.length == 0) { return Collections.emptyList(); } for (String pks : sa) { try { int pk = Integer.parseInt(pks); Object ent = session.get(emd.getJavaType(), pk); if (ent != null) { ret.add(ent); } } catch (NumberFormatException ex) { Log.warn("Cannot parse pk: " + prop); } } return ret; }
/** * This method is called at the start of an element. * * @param tagName the tag name. * @param attrs the attributes. * * @throws SAXException if there is a parsing error. * @throws XmlReaderException if there is a reader error. */ public final void startElement(final String tagName, final Attributes attrs) throws XmlReaderException, SAXException { if (this.firstCall) { if (!this.tagName.equals(tagName)) { throw new SAXException("Expected <" + this.tagName + ">, found <" + tagName + ">"); } this.firstCall = false; startParsing(attrs); } else { final XmlReadHandler childHandler = getHandlerForChild(tagName, attrs); if (childHandler == null) { Log.warn ("Unknown tag <" + tagName + ">"); return; } childHandler.init(getRootHandler(), tagName); this.rootHandler.recurse(childHandler, tagName, attrs); } }
/** * Sets the parameters of this description object to match the supplied object. * * @param o the object (should be an instance of <code>URL</code>). * * @throws ObjectFactoryException if the object is not an instance of <code>URL</code>. */ public void setParameterFromObject(final Object o) throws ObjectFactoryException { if (!(o instanceof URL)) { throw new ObjectFactoryException("Is no instance of java.net.URL"); } final URL comp = (URL) o; final String baseURL = getConfig().getConfigProperty(Parser.CONTENTBASE_KEY); try { final URL bURL = new URL(baseURL); setParameter("value", IOUtils.getInstance().createRelativeURL(comp, bURL)); } catch (Exception e) { Log.warn("BaseURL is invalid: ", e); } setParameter("value", comp.toExternalForm()); }