public boolean contains( CSSValue value ) { for ( int i = 0; i < values.length; i++ ) { CSSValue cssValue = values[ i ]; if ( ObjectUtilities.equal( cssValue, value ) ) { return true; } } return false; }
/** * Tries to create a new instance of the given class. This is a short cut for the common bean instantiation code. * * @param className the class name as String, never null. * @param source the source class, from where to get the classloader. * @return the instantiated object or null, if an error occured. * @deprecated This class is not typesafe and instantiates the specified object without any additional checks. */ public static Object loadAndInstantiate( final String className, final Class source ) { return loadAndInstantiate( className, source, null ); }
/** * Creates a new PDF export task. */ public ReportExportTask( final MasterReport report, final SwingGuiContext swingGuiContext, String targetPath, Boolean createParentFolder ) { if ( report == null ) { throw new NullPointerException( "ReportExportTask(..): Report parameter cannot be null" ); } this.report = report; this.statusListener = swingGuiContext.getStatusListener(); // Check if the current Locale is supported: // If not, use the default (US) locale. Locale locale = swingGuiContext.getLocale(); try { ResourceBundle.getBundle( BASE_RESOURCE_CLASS, swingGuiContext.getLocale() ); } catch ( MissingResourceException e ) { locale = Locale.US; } this.messages = new Messages( locale, BASE_RESOURCE_CLASS, ObjectUtilities.getClassLoader( ReportExportTask.class ) ); this.targetPath = targetPath; this.createParentFolder = createParentFolder; }
/** * Determines if this instance of the object is equals to another Object * * @return <code>true</code> if the supplied object is equivalent to this object, <code>false</code> otherwise */ public boolean equals( Object obj ) { if ( obj instanceof CSSFunctionValue ) { CSSFunctionValue that = (CSSFunctionValue) obj; return ( ObjectUtilities.equal( this.functionName, that.functionName ) && ObjectUtilities.equalArray( this.parameters, that.parameters ) ); } else { return false; } }
public Messages getBundle( final Locale locale ) { if ( locale == null ) { throw new NullPointerException(); } if ( lastMessages == null || ObjectUtilities.equal( locale, lastLocale ) == false ) { lastMessages = new Messages( locale, bundleLocation, ObjectUtilities.getClassLoader( AbstractMetaData.class ) ); lastLocale = locale; } return lastMessages; }
public void load( final String resourceName ) { if ( resourceName == null ) { throw new NullPointerException(); } final InputStream in = ObjectUtilities.getResourceRelativeAsStream( resourceName, PrinterDriver.class ); if ( in == null ) { PrinterSpecificationManager.logger.error( "Printer definition is missing: " + resourceName ); return; } try { try { load( in ); } finally { in.close(); } } catch ( IOException e ) { PrinterSpecificationManager.logger.error( "Unable to load printer definition file " + resourceName, e ); } }
/** * Returns the inputstream for the resource specified by the <strong>absolute</strong> name. * * @param name the name of the resource * @param context the source class * @return the url of the resource or null, if not found. */ public static InputStream getResourceAsStream( final String name, final Class context ) { final URL url = getResource( name, context ); if ( url == null ) { return null; } try { return url.openStream(); } catch ( IOException e ) { return null; } }
/** * Determines if this instance of the object is equals to another Object * * @return <code>true</code> if the supplied object is equivalent to this object, <code>false</code> otherwise */ public boolean equals( Object obj ) { if ( obj instanceof CSSValueList ) { CSSValueList that = (CSSValueList) obj; return ObjectUtilities.equalArray( this.values, that.values ); } else { return false; } }
/** * Creates a deep copy of this HashNMap. * * @return a clone. * @throws CloneNotSupportedException this should never happen. * @noinspection unchecked */ public Object clone() throws CloneNotSupportedException { final HashNMap<K, V> map = (HashNMap) super.clone(); map.table = (HashMap) table.clone(); final Iterator iterator = map.table.entrySet().iterator(); while ( iterator.hasNext() ) { final Map.Entry entry = (Map.Entry) iterator.next(); final List list = (List) entry.getValue(); if ( list != null ) { entry.setValue( ObjectUtilities.clone( list ) ); } } return map; }
private boolean equalsMap( final Map otherValues ) { if ( otherValues.size() != values.size() ) { return false; } for ( int i = 0; i < names.length; i++ ) { final String key = names[i]; final Object value = values.get( key ); final Object otherValue = otherValues.get( key ); if ( value == null && otherValue == null ) { continue; } if ( value instanceof Object[] && otherValue instanceof Object[] ) { if ( ObjectUtilities.equalArray( (Object[]) value, (Object[]) otherValue ) == false ) { return false; } } else if ( ObjectUtilities.equal( value, otherValue ) == false ) { return false; } } return true; }
/** * 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 resourceName the file name of the stored properties. * @param resourceSource the class to which relative resource paths are resolved. */ public void load( final String resourceName, final Class resourceSource ) { final InputStream in = ObjectUtilities.getResourceRelativeAsStream ( resourceName, resourceSource ); if ( in != null ) { try { load( in ); } finally { try { in.close(); } catch ( IOException e ) { // ignore } } } else { LOGGER.debug( "Configuration file not found in the classpath: " + resourceName ); } }
/** * Returns the inputstream for the resource specified by the <strong>absolute</strong> name. * * @param name the name of the resource * @param context the source class * @return the url of the resource or null, if not found. */ public static InputStream getResourceAsStream(final String name, final Class context) { final URL url = getResource(name, context); if (url == null) { return null; } try { return url.openStream(); } catch (IOException e) { return null; } }
private int findInserationPoint( final Object[] key, final int inserationPoint ) { for ( int i = inserationPoint; i < entries.size(); i++ ) { final Object[] existingKey = entries.get( i ); if ( ObjectUtilities.equalArray( existingKey, key ) ) { return i; } } return -1; }
/** * Creates a deep copy of this HashNMap. * * @return a clone. * @throws CloneNotSupportedException this should never happen. * @noinspection unchecked */ public Object clone() throws CloneNotSupportedException { final HashNMap<K,V> map = (HashNMap) super.clone(); map.table = (HashMap) table.clone(); final Iterator iterator = map.table.entrySet().iterator(); while (iterator.hasNext()) { final Map.Entry entry = (Map.Entry) iterator.next(); final List list = (List) entry.getValue(); if (list != null) { entry.setValue(ObjectUtilities.clone(list)); } } return map; }
public WrapperWMFDrawableFactoryModule() { parent = ObjectUtilities.loadAndInstantiate ( "org.pentaho.reporting.libraries.resourceloader.modules.factory.wmf.WMFImageFactoryModule", WrapperWMFImageFactoryModule.class, FactoryModule.class ); }
/** * Creates a new instance based on locale. */ private Messages( Locale locale ) { super( locale, "org.pentaho.reporting.engine.classic.core.parameters.messages", ObjectUtilities .getClassLoader( Messages.class ) ); } }
private boolean equalsMap( final Map<String, Object> values, final Map<String, Object> otherValues ) { if ( otherValues.size() != values.size() ) { return false; } for ( final String key : values.keySet() ) { final Object value = values.get( key ); final Object otherValue = otherValues.get( key ); if ( value == null && otherValue == null ) { continue; } if ( value instanceof Object[] && otherValue instanceof Object[] ) { if ( ObjectUtilities.equalArray( (Object[]) value, (Object[]) otherValue ) == false ) { return false; } } else if ( ObjectUtilities.equal( value, otherValue ) == false ) { return false; } } return true; }
/** * Loads the default module description from the file "module.properties". This file must be in the same package as * the implementing class. * * @throws ModuleInitializeException if an error occurs. */ protected void loadModuleInfo() throws ModuleInitializeException { final InputStream in = ObjectUtilities.getResourceRelativeAsStream( "module.properties", getClass() ); if ( in == null ) { throw new ModuleInitializeException ( "File 'module.properties' not found in module package." ); } loadModuleInfo( in ); }
/** * Returns the URL of a report. * * @param name * the report name. * @return The URL (or <code>null</code>). * @throws java.io.IOException * if there is an I/O problem. */ public URL findReport( final String name ) throws IOException { final URL in = ObjectUtilities.getResource( name, ReportConverter.class ); if ( in != null ) { return in; } final File f = new File( name ); if ( f.canRead() ) { return f.toURL(); } return null; }