Example usage for org.apache.commons.lang NullArgumentException NullArgumentException

List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException

Introduction

In this page you can find the example usage for org.apache.commons.lang NullArgumentException NullArgumentException.

Prototype

public NullArgumentException(String argName) 

Source Link

Document

Instantiates with the given argument name.

Usage

From source file:com.eyeq.pivot4j.impl.PivotModelImpl.java

/**
 * Sets the mdxQuery./*from www . j a  v  a2  s .c om*/
 * 
 * @param mdxQuery
 *            The mdxQuery to set
 */
public void setMdx(String mdxQuery) {
    if (mdxQuery == null) {
        throw new NullArgumentException("mdxQuery");
    }

    this.mdxQuery = mdxQuery;

    String mdx = normalizeMdx(mdxQuery);
    if (!mdx.equals(normalizeMdx(getCurrentMdx()))) {
        onMdxChanged(mdx);
    }
}

From source file:de.tiqsolutions.hdfs.HadoopFileSystemProvider.java

@Override
public boolean isSameFile(Path path, Path path2) throws IOException {
    if (path == null)
        throw new NullArgumentException("path");
    if (path2 == null)
        throw new NullArgumentException("path2");
    FileSystem fs = path.getFileSystem();
    if (!HadoopFileSystem.class.isInstance(fs))
        throw new IllegalArgumentException("path");
    return ((HadoopFileSystem) fs).isSameFile(path, path2);

}

From source file:com.wavemaker.json.JSONMarshaller.java

private static boolean handleObjectInternal(Object object, Object root, String key, Object value,
        boolean firstProperty, JSONState js, Writer writer, Stack<Object> touchedObjects,
        Stack<String> propertyNames, boolean sort, FieldDefinition fieldDefinition, int arrayLevel,
        TypeState typeState, boolean prettyPrint, int level, Logger logger) throws IOException {

    if (fieldDefinition == null) {
        throw new NullArgumentException("fieldDefinition");
    }/*from   ww  w.  j a va  2s  . c  om*/

    propertyNames.push(key);
    String propertyName = getPropertyName(propertyNames, js);
    try {
        if (js.getExcludes().contains(propertyName)) {
            return firstProperty;
        }

        if (js.getPropertyFilter() != null) {
            if (js.getPropertyFilter().filter(object, key, value)) {
                return firstProperty;
            }
        }

        // cycle
        if (isCycle(value, touchedObjects, propertyName, js)) {
            if (logger.isInfoEnabled()) {
                logger.info(MessageResource.JSON_CYCLE_FOUND.getMessage(value, js.getCycleHandler()));
            }

            if (js.getCycleHandler().equals(JSONState.CycleHandler.FAIL)) {
                throw new WMRuntimeException(MessageResource.JSON_CYCLE_FOUND, value, js.getCycleHandler());
            } else if (js.getCycleHandler().equals(JSONState.CycleHandler.NULL)) {
                value = null;
            } else if (js.getCycleHandler().equals(JSONState.CycleHandler.NO_PROPERTY)) {
                return firstProperty;
            } else {
                throw new WMRuntimeException(MessageResource.JSON_BAD_CYCLE_HANDLER, js.getCycleHandler());
            }
        }

        if (!firstProperty) {
            writer.write(',');
        }

        if (prettyPrint) {
            writer.write("\n");
            writeIndents(writer, level);
        }

        if (js.isUnquoteKeys()) {
            writer.write(key + ":");
        } else {
            writer.write("\"" + key + "\":");
        }

        if (prettyPrint) {
            writer.write(" ");
        }

        doMarshal(writer, value, root, js, sort, false, touchedObjects, propertyNames, fieldDefinition,
                arrayLevel, typeState, prettyPrint, level, logger);

        if (firstProperty) {
            firstProperty = false;
        }

        return firstProperty;
    } finally {
        propertyNames.pop();
    }
}

From source file:com.eyeq.pivot4j.ui.AbstractPivotRenderer.java

/**
 * @see com.eyeq.pivot4j.ui.property.PropertySupport#restoreState(java.io.Serializable)
 *///from   w w w  . j ava2s.c o m
@SuppressWarnings("unchecked")
@Override
public void restoreState(Serializable state) {
    if (state == null) {
        throw new NullArgumentException("state");
    }

    Serializable[] states = (Serializable[]) state;

    this.showDimensionTitle = (Boolean) states[0];
    this.showParentMembers = (Boolean) states[1];
    this.hideSpans = (Boolean) states[2];
    this.aggregatorNames = (Map<AggregatorKey, List<String>>) states[3];

    initializeProperties();

    if (states[4] != null && cellProperties != null) {
        this.cellProperties.restoreState(states[4]);
    }

    if (states[5] != null && headerProperties != null) {
        this.headerProperties.restoreState(states[5]);
    }
}

From source file:io.github.divinespear.maven.plugin.JpaSchemaGeneratorMojo.java

private void generate() throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();

    /*/*from w w  w. j a  va  2s  .  c o  m*/
     * Common JPA options
     */
    // mode
    map.put(PersistenceUnitProperties.SCHEMA_GENERATION_DATABASE_ACTION, this.databaseAction.toLowerCase());
    map.put(PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPTS_ACTION, this.scriptAction.toLowerCase());
    // output files
    if (this.isScriptTarget()) {
        if (this.outputDirectory == null) {
            throw new NullArgumentException("outputDirectory is required for script generation.");
        }
        map.put(PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPTS_CREATE_TARGET,
                this.getCreateOutputFile().toURI().toString());
        map.put(PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPTS_DROP_TARGET,
                this.getDropOutputFile().toURI().toString());

    }
    // database emulation options
    map.put(PersistenceUnitProperties.SCHEMA_DATABASE_PRODUCT_NAME, this.databaseProductName);
    map.put(PersistenceUnitProperties.SCHEMA_DATABASE_MAJOR_VERSION,
            this.databaseMajorVersion == null ? null : String.valueOf(this.databaseMajorVersion));
    map.put(PersistenceUnitProperties.SCHEMA_DATABASE_MINOR_VERSION,
            this.databaseMinorVersion == null ? null : String.valueOf(this.databaseMinorVersion));
    // database options
    map.put(PersistenceUnitProperties.JDBC_DRIVER, this.jdbcDriver);
    map.put(PersistenceUnitProperties.JDBC_URL, this.jdbcUrl);
    map.put(PersistenceUnitProperties.JDBC_USER, this.jdbcUser);
    map.put(PersistenceUnitProperties.JDBC_PASSWORD, this.jdbcPassword);
    // source selection
    map.put(PersistenceUnitProperties.SCHEMA_GENERATION_CREATE_SOURCE, this.createSourceMode);
    if (this.createSourceFile == null) {
        if (!PersistenceUnitProperties.SCHEMA_GENERATION_METADATA_SOURCE.equals(this.createSourceMode)) {
            throw new IllegalArgumentException(
                    "create source file is required for mode " + this.createSourceMode);
        }
    } else {
        map.put(PersistenceUnitProperties.SCHEMA_GENERATION_CREATE_SCRIPT_SOURCE,
                this.createSourceFile.toURI().toString());
    }
    map.put(PersistenceUnitProperties.SCHEMA_GENERATION_DROP_SOURCE, this.dropSourceMode);
    if (this.dropSourceFile == null) {
        if (!PersistenceUnitProperties.SCHEMA_GENERATION_METADATA_SOURCE.equals(this.dropSourceMode)) {
            throw new IllegalArgumentException("drop source file is required for mode " + this.dropSourceMode);
        }
    } else {
        map.put(PersistenceUnitProperties.SCHEMA_GENERATION_DROP_SCRIPT_SOURCE,
                this.dropSourceFile.toURI().toString());
    }

    /*
     * EclipseLink specific
     */
    // persistence.xml
    map.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, this.persistenceXml);

    /*
     * Hibernate specific
     */
    // naming strategy
    map.put(AvailableSettings.NAMING_STRATEGY, this.namingStrategy);
    // auto-detect
    map.put(AvailableSettings.AUTODETECTION, "class,hbm");
    // dialect (without jdbc connection)
    if (this.dialect == null && this.jdbcUrl == null) {
        DialectResolutionInfo info = new DialectResolutionInfo() {
            @Override
            public String getDriverName() {
                return null;
            }

            @Override
            public int getDriverMinorVersion() {
                return 0;
            }

            @Override
            public int getDriverMajorVersion() {
                return 0;
            }

            @Override
            public String getDatabaseName() {
                return databaseProductName;
            }

            @Override
            public int getDatabaseMinorVersion() {
                return databaseMinorVersion;
            }

            @Override
            public int getDatabaseMajorVersion() {
                return databaseMajorVersion;
            }
        };
        Dialect detectedDialect = StandardDialectResolver.INSTANCE.resolveDialect(info);
        this.dialect = detectedDialect.getClass().getName();
    }
    if (this.dialect != null) {
        map.put(org.hibernate.cfg.AvailableSettings.DIALECT, this.dialect);
    }

    if (!this.isDatabaseTarget() && StringUtils.isEmpty(this.jdbcUrl)) {
        map.put(AvailableSettings.SCHEMA_GEN_CONNECTION, new ConnectionMock(this.getDatabaseProductName(),
                this.getDatabaseMajorVersion(), this.getDatabaseMinorVersion()));
    }

    /* force override JTA to RESOURCE_LOCAL */
    map.put(PersistenceUnitProperties.TRANSACTION_TYPE, "RESOURCE_LOCAL");
    map.put(PersistenceUnitProperties.JTA_DATASOURCE, null);
    map.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, null);
    map.put(PersistenceUnitProperties.VALIDATION_MODE, "NONE");

    Persistence.generateSchema(this.persistenceUnitName, map);
}

From source file:com.eyeq.pivot4j.ui.AbstractPivotRenderer.java

/**
 * @see com.eyeq.pivot4j.ui.property.PropertySupport#saveSettings(org.apache.commons.configuration.HierarchicalConfiguration)
 *//* w w w .  j a v a 2s . c om*/
@Override
public void saveSettings(HierarchicalConfiguration configuration) {
    if (configuration == null) {
        throw new NullArgumentException("configuration");
    }

    configuration.setDelimiterParsingDisabled(true);

    if (configuration.getLogger() == null) {
        configuration.setLogger(LogFactory.getLog(getClass()));
    }

    configuration.addProperty("showDimensionTitle", showDimensionTitle);
    configuration.addProperty("showParentMembers", showParentMembers);
    configuration.addProperty("hideSpans", hideSpans);

    if (!aggregatorNames.isEmpty()) {
        int index = 0;

        for (AggregatorKey key : aggregatorNames.keySet()) {
            Axis axis = key.getAxis();
            AggregatorPosition position = key.getPosition();

            List<String> names = aggregatorNames.get(key);

            for (String name : names) {
                configuration.addProperty(String.format("aggregations.aggregation(%s)[@name]", index), name);
                configuration.addProperty(String.format("aggregations.aggregation(%s)[@axis]", index),
                        axis.name());
                configuration.addProperty(String.format("aggregations.aggregation(%s)[@position]", index),
                        position.name());

                index++;
            }
        }
    }

    if (cellProperties != null) {
        configuration.addProperty("properties.cell", "");

        cellProperties.saveSettings(configuration.configurationAt("properties.cell"));
    }

    if (headerProperties != null) {
        configuration.addProperty("properties.header", "");

        headerProperties.saveSettings(configuration.configurationAt("properties.header"));
    }
}

From source file:de.tiqsolutions.hdfs.HadoopFileSystemProvider.java

@Override
public Map<String, Object> readAttributes(Path path, String attributes, LinkOption... options)
        throws IOException {
    if (attributes == null)
        throw new NullArgumentException("attributes");
    String[] args = attributes.split(":", 2);

    if (args.length == 2) {
        switch (args[0]) {
        case BasicFileAttributeViewImpl.NAME:
            return ((BasicFileAttributeViewImpl) getFileAttributeView(path, BasicFileAttributeView.class,
                    options)).readAttributes(args[1]);
        case PosixFileAttributeViewImpl.NAME:
            return ((PosixFileAttributeViewImpl) getFileAttributeView(path, PosixFileAttributeView.class,
                    options)).readAttributes(args[1]);
        case HadoopFileAttributeViewImpl.NAME:
            return ((HadoopFileAttributeViewImpl) getFileAttributeView(path, HadoopFileAttributeView.class,
                    options)).readAttributes(args[1]);
        default://from w ww .  j  a  v a  2  s  .com
            throw new UnsupportedOperationException(String.format("attributeview %s not supported", args[0]));
        }
    }
    // default to basic
    return ((BasicFileAttributeViewImpl) getFileAttributeView(path, BasicFileAttributeView.class, options))
            .readAttributes(attributes);
}

From source file:com.eyeq.pivot4j.ui.AbstractPivotRenderer.java

/**
 * @see com.eyeq.pivot4j.state.Configurable#restoreSettings(org.apache.commons.configuration.HierarchicalConfiguration)
 *//*from   w w w .  j a  v a2s.  c  o  m*/
@Override
public void restoreSettings(HierarchicalConfiguration configuration) {
    if (configuration == null) {
        throw new NullArgumentException("configuration");
    }

    this.showDimensionTitle = configuration.getBoolean("showDimensionTitle", true);
    this.showParentMembers = configuration.getBoolean("showParentMembers", false);
    this.hideSpans = configuration.getBoolean("hideSpans", false);

    List<HierarchicalConfiguration> aggregationSettings = configuration
            .configurationsAt("aggregations.aggregation");

    this.aggregatorNames.clear();

    for (HierarchicalConfiguration aggConfig : aggregationSettings) {
        String name = aggConfig.getString("[@name]");

        if (name != null) {
            Axis axis = Axis.Standard.valueOf(aggConfig.getString("[@axis]"));

            AggregatorPosition position = AggregatorPosition.valueOf(aggConfig.getString("[@position]"));

            AggregatorKey key = new AggregatorKey(axis, position);

            List<String> names = aggregatorNames.get(key);

            if (names == null) {
                names = new LinkedList<String>();
                aggregatorNames.put(key, names);
            }

            if (!names.contains(name)) {
                names.add(name);
            }
        }
    }

    initializeProperties();

    if (cellProperties != null) {
        try {
            cellProperties.restoreSettings(configuration.configurationAt("properties.cell"));
        } catch (IllegalArgumentException e) {
        }
    }

    if (headerProperties != null) {
        try {
            headerProperties.restoreSettings(configuration.configurationAt("properties.header"));
        } catch (IllegalArgumentException e) {
        }
    }
}

From source file:com.eyeq.pivot4j.impl.PivotModelImpl.java

/**
 * @see com.eyeq.pivot4j.state.Bookmarkable#restoreState(java.io.Serializable)
 *//*w  ww . j a v a 2s.c o  m*/
public synchronized void restoreState(Serializable state) {
    if (state == null) {
        throw new NullArgumentException("state");
    }

    Serializable[] states = (Serializable[]) state;

    setMdx((String) states[0]);

    if (!isInitialized()) {
        initialize();
    }

    // sorting
    if (states[1] == null) {
        this.sortPosMembers = null;
    } else {
        try {
            Cube cube = getCube();

            Serializable[] sortStates = (Serializable[]) states[1];

            String[] sortPosUniqueNames = (String[]) sortStates[0];
            if (sortPosUniqueNames == null) {
                this.sortPosMembers = null;
            } else {
                this.sortPosMembers = new ArrayList<Member>(sortPosUniqueNames.length);

                for (int i = 0; i < sortPosUniqueNames.length; i++) {
                    Member member = cube.lookupMember(
                            IdentifierNode.parseIdentifier(sortPosUniqueNames[i]).getSegmentList());
                    if (member == null) {
                        if (logger.isWarnEnabled()) {
                            logger.warn("Sort position member not found " + sortPosUniqueNames[i]);
                        }

                        break;
                    }

                    sortPosMembers.add(member);
                }

                this.topBottomCount = (Integer) sortStates[1];
                this.sortCriteria = (SortCriteria) sortStates[2];
                this.sorting = (Boolean) sortStates[3];
            }
        } catch (OlapException e) {
            throw new PivotException(e);
        }
    }

    this.cellSet = null;

    queryAdapter.restoreState(states[2]);
}

From source file:com.eyeq.pivot4j.impl.PivotModelImpl.java

/**
 * @see com.eyeq.pivot4j.state.Configurable#saveSettings(org.apache.commons.configuration.HierarchicalConfiguration)
 *//*from   ww  w  . ja va  2s. c o m*/
@Override
public synchronized void saveSettings(HierarchicalConfiguration configuration) {
    if (configuration == null) {
        throw new NullArgumentException("configuration");
    }

    if (configuration.getLogger() == null) {
        configuration.setLogger(LogFactory.getLog(getClass()));
    }

    if (isInitialized()) {
        configuration.addProperty("mdx", getCurrentMdx());
    } else {
        configuration.addProperty("mdx", mdxQuery);
    }

    if (sorting) {
        configuration.addProperty("sort[@enabled]", sorting);

        if (queryAdapter.getQuaxToSort() != null) {
            configuration.addProperty("sort[@ordinal]", queryAdapter.getQuaxToSort().getOrdinal());
        }

        if (sortCriteria != null) {
            configuration.addProperty("sort[@criteria]", sortCriteria.name());
            configuration.addProperty("sort[@topBottomCount]", topBottomCount);
            if (isSorting() && sortPosMembers != null) {
                int index = 0;
                for (Member member : sortPosMembers) {
                    configuration.addProperty(String.format("sort.member(%s)", index++),
                            member.getUniqueName());
                }
            }
        }
    }
}