Package org.apache.commons.lang

Examples of org.apache.commons.lang.IllegalClassException


      for (NameValuePair p : ((ResourceCreationSpecifier) spec).getMetaData()
              .getConfigurationParameterSettings().getParameterSettings()) {
        settings.put(p.getName(), p.getValue());
      }
    } else {
      throw new IllegalClassException("Unsupported resource specifier class [" + spec.getClass()
              + "]");
    }
    return settings;
  }
View Full Code Here


   *           if the value is not of a supported type for the given specifier.
   */
  public static void setParameter(ResourceSpecifier aSpec, String name, Object value) {
    if (aSpec instanceof CustomResourceSpecifier) {
      if (!(value instanceof String || value == null)) {
        throw new IllegalClassException(String.class, value);
      }
      CustomResourceSpecifier spec = (CustomResourceSpecifier) aSpec;

      // If the parameter is already there, update it
      boolean found = false;
      for (Parameter p : spec.getParameters()) {
        if (p.getName().equals(name)) {
          p.setValue((String) value);
          found = true;
        }
      }

      // If the parameter is not there, add it
      if (!found) {
        Parameter[] params = new Parameter[spec.getParameters().length + 1];
        System.arraycopy(spec.getParameters(), 0, params, 0, spec.getParameters().length);
        params[params.length - 1] = new Parameter_impl();
        params[params.length - 1].setName(name);
        params[params.length - 1].setValue((String) value);
        spec.setParameters(params);
      }
    } else if (aSpec instanceof ResourceCreationSpecifier) {
      ResourceMetaData md = ((ResourceCreationSpecifier) aSpec).getMetaData();

      if (md.getConfigurationParameterDeclarations().getConfigurationParameter(null, name) == null) {
        throw new IllegalArgumentException("Cannot set undeclared parameter [" + name + "]");
      }

      md.getConfigurationParameterSettings().setParameterValue(name, value);
    } else if (aSpec instanceof ConfigurableDataResourceSpecifier) {
      ResourceMetaData md = ((ConfigurableDataResourceSpecifier) aSpec).getMetaData();

      if (md.getConfigurationParameterDeclarations().getConfigurationParameter(null, name) == null) {
        throw new IllegalArgumentException("Cannot set undeclared parameter [" + name + "]");
      }

      md.getConfigurationParameterSettings().setParameterValue(name, value);
    } else {
      throw new IllegalClassException("Unsupported resource specifier class [" + aSpec.getClass()
              + "]");
    }
  }
View Full Code Here

    BeanWrapperImpl beanWrapperImpl = new BeanWrapperImpl(mapperClass);
    Object outputObject = beanWrapperImpl.getWrappedInstance();
    if (outputObject instanceof GenericMapper) {
      mapper = (GenericMapper) outputObject;
    } else {
      throw new IllegalClassException(GenericMapper.class, beanWrapperImpl.getRootClass());
    }
    return mapper;
  }
View Full Code Here

    BeanWrapperImpl beanWrapperImpl = new BeanWrapperImpl(mapperClazz);
    Object outputObject = beanWrapperImpl.getWrappedInstance();
    if (outputObject instanceof GenericMapper) {
      mapper = (GenericMapper) outputObject;
    } else {
      throw new IllegalClassException(GenericMapper.class, beanWrapperImpl.getRootClass());
    }
    return mapper;
  }
View Full Code Here

      for (NameValuePair p : ((ResourceCreationSpecifier) spec).getMetaData()
              .getConfigurationParameterSettings().getParameterSettings()) {
        settings.put(p.getName(), p.getValue());
      }
    } else {
      throw new IllegalClassException("Unsupported resource specifier class [" + spec.getClass()
              + "]");
    }
    return settings;
  }
View Full Code Here

   *           if the value is not of a supported type for the given specifier.
   */
  public static void setParameter(ResourceSpecifier aSpec, String name, Object value) {
    if (aSpec instanceof CustomResourceSpecifier) {
      if (!(value instanceof String || value == null)) {
        throw new IllegalClassException(String.class, value);
      }
      CustomResourceSpecifier spec = (CustomResourceSpecifier) aSpec;

      // If the parameter is already there, update it
      boolean found = false;
      for (Parameter p : spec.getParameters()) {
        if (p.getName().equals(name)) {
          p.setValue((String) value);
          found = true;
        }
      }

      // If the parameter is not there, add it
      if (!found) {
        Parameter[] params = new Parameter[spec.getParameters().length + 1];
        System.arraycopy(spec.getParameters(), 0, params, 0, spec.getParameters().length);
        params[params.length - 1] = new Parameter_impl();
        params[params.length - 1].setName(name);
        params[params.length - 1].setValue((String) value);
        spec.setParameters(params);
      }
    } else if (aSpec instanceof ResourceCreationSpecifier) {
      ResourceMetaData md = ((ResourceCreationSpecifier) aSpec).getMetaData();

      if (md.getConfigurationParameterDeclarations().getConfigurationParameter(null, name) == null) {
        throw new IllegalArgumentException("Cannot set undeclared parameter [" + name + "]");
      }

      md.getConfigurationParameterSettings().setParameterValue(name, value);
    } else if (aSpec instanceof ConfigurableDataResourceSpecifier) {
      ResourceMetaData md = ((ConfigurableDataResourceSpecifier) aSpec).getMetaData();

      if (md.getConfigurationParameterDeclarations().getConfigurationParameter(null, name) == null) {
        throw new IllegalArgumentException("Cannot set undeclared parameter [" + name + "]");
      }

      md.getConfigurationParameterSettings().setParameterValue(name, value);
    } else {
      throw new IllegalClassException("Unsupported resource specifier class [" + aSpec.getClass()
              + "]");
    }
  }
View Full Code Here

        for(String anItem : qualifiedItems) {
          if (type instanceof State) {
            eventPublisher.postUpdate(anItem, (State) type);
          } else {
            throw new IllegalClassException("Cannot process update of type " + type.toString());
          }
        }
      }
    }   
  }
View Full Code Here

              if (type instanceof Command && isCommandGA(destination)) {
                eventPublisher.postCommand(itemName, (Command) type);
              } else if (type instanceof State) {
                eventPublisher.postUpdate(itemName, (State) type);
              } else {
                throw new IllegalClassException("Cannot process datapoint of type " + type.toString());
              }               

              logger.trace("Processed event (item='{}', type='{}', destination='{}')", itemName, type.toString(), destination.toString());
              return;
            }
View Full Code Here

              if( provider.getAcceptedDataTypes(anItem).contains(sonosCommandType.getTypeClass())) {
                if(newState != null) {
                  eventPublisher.postUpdate(anItem,(State) newState);
                } else {
                  throw new IllegalClassException(
                      "Cannot process update for the command of type "
                          + sonosCommandType
                          .toString());
                }
              } else {
View Full Code Here

    private DataSourceHolder getDataSourceByKey(Class<?> daoClass, String key) {
        if (applicationContext.containsBean(key)) {
            Object dataSource = applicationContext.getBean(key);
            if (!(dataSource instanceof DataSource) && !(dataSource instanceof DataSourceFactory)) {
                throw new IllegalClassException("expects DataSource or DataSourceFactory, but a "
                        + dataSource.getClass().getName());
            }
            if (logger.isDebugEnabled()) {
                logger.debug("found dataSource: " + key + " for DAO " + daoClass.getName());
            }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.IllegalClassException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.