/**
         * Transformer method that performs validation.
         *
         * @param paramTypes  the constructor parameter types
         * @param args  the constructor arguments
         * @return an instantiate transformer
         */
        public static Transformer getInstance(java.lang.Class[] paramTypes, Object[] args)
        {
            if (((paramTypes == null) && (args != null))
                || ((paramTypes != null) && (args == null))
                || ((paramTypes != null) && (args != null) && (paramTypes.Length != args.Length)))
            {
                throw new java.lang.IllegalArgumentException("Parameter types must match the arguments");
            }

            if (paramTypes == null || paramTypes.Length == 0)
            {
                return NO_ARG_INSTANCE;
            }
            else
            {
                paramTypes = (java.lang.Class[])paramTypes.clone();
                args = (Object[])args.clone();
            }
            return new InstantiateTransformer(paramTypes, args);
        }
Exemple #2
0
 /**
  * <p>Returns the length of the duration in milli-seconds.</p>
  *
  * <p>If the seconds field carries more digits than milli-second order,
  * those will be simply discarded (or in other words, rounded to zero.)
  * For example, for any Calendar value <code>x</code>,</p>
  * <pre>
  * <code>new Duration("PT10.00099S").getTimeInMills(x) == 10000</code>.
  * <code>new Duration("-PT10.00099S").getTimeInMills(x) == -10000</code>.
  * </pre>
  *
  * <p/>
  * Note that this method uses the {@link #addTo(Calendar)} method,
  * which may work incorrectly with <code>Duration</code> objects with
  * very large values in its fields. See the {@link #addTo(Calendar)}
  * method for details.
  *
  * @param startInstant
  *      The length of a month/year varies. The <code>startInstant</code> is
  *      used to disambiguate this variance. Specifically, this method
  *      returns the difference between <code>startInstant</code> and
  *      <code>startInstant+duration</code>
  *
  * @return milliseconds between <code>startInstant</code> and
  *   <code>startInstant</code> plus this <code>Duration</code>
  *
  * @throws NullPointerException if <code>startInstant</code> parameter
  * is null.
  *
  */
 public long getTimeInMillis(java.util.Calendar startInstant)
 {
     java.util.Calendar cal = (java.util.Calendar)startInstant.clone();
     addTo(cal);
     return getCalendarTimeInMillis(cal)
                 - getCalendarTimeInMillis(startInstant);
 }
        /**
         * Factory method that performs validation.
         *
         * @param classToInstantiate  the class to instantiate, not null
         * @param paramTypes  the constructor parameter types
         * @param args  the constructor arguments
         * @return a new instantiate factory
         */
        public static Factory getInstance(java.lang.Class classToInstantiate, java.lang.Class[] paramTypes, Object[] args)
        {
            if (classToInstantiate == null)
            {
                throw new java.lang.IllegalArgumentException("Class to instantiate must not be null");
            }
            if (((paramTypes == null) && (args != null))
                || ((paramTypes != null) && (args == null))
                || ((paramTypes != null) && (args != null) && (paramTypes.Length != args.Length)))
            {
                throw new java.lang.IllegalArgumentException("Parameter types must match the arguments");
            }

            if (paramTypes == null || paramTypes.Length == 0)
            {
                return new InstantiateFactory(classToInstantiate);
            }
            else
            {
                paramTypes = (java.lang.Class[])paramTypes.clone();
                args = (Object[])args.clone();
                return new InstantiateFactory(classToInstantiate, paramTypes, args);
            }
        }