Examples of Class


Examples of java.lang.Class

  public Object createInstance( String conceptName )
     throws InstantiationException
  {
   try
     {
     Class type = getClass().forName(conceptName);
     Object res = type.newInstance();
     ownedObjects.add(res);
     return res;
     }
    catch( Exception ex )
     {
View Full Code Here

Examples of java.lang.Class

                try {
                    URL[] urls = new URL[1];
                    urls[0] = new URL(factoryJar);
                    ClassLoader loader = new URLClassLoader(urls,
                        BagFactory.class.getClassLoader());
                    Class c = Class.forName(factoryName, true, loader);
                    Object o = c.newInstance();
                    if (!(o instanceof BagFactory)) {
                        throw new RuntimeException("Provided factory " +
                            factoryName + " does not extend BagFactory!");
                    }
                    gSelf = (BagFactory)o;
View Full Code Here

Examples of java.lang.Class

                try {
                    URL[] urls = new URL[1];
                    urls[0] = new URL(factoryJar);
                    ClassLoader loader = new URLClassLoader(urls,
                        TupleFactory.class.getClassLoader());
                    Class c = Class.forName(factoryName, true, loader);
                    Object o = c.newInstance();
                    if (!(o instanceof TupleFactory)) {
                        throw new RuntimeException("Provided factory " +
                            factoryName + " does not extend TupleFactory!");
                    }
                    gSelf = (TupleFactory)o;
View Full Code Here

Examples of java.lang.Class

            {
                for( int i = 0; i < field.length; i++)
                {
                    if( ! Modifier.isStatic( field[i].getModifiers()))
                    {
                        Class fieldClass = field[i].getType();
                        if( fieldClass.isArray() || ! fieldClass.isPrimitive())
                            coeff[1]++;
                        else // Is simple primitive
                        {
                            String name = fieldClass.getName();

                            if( name.equals( "int") || name.equals( "I"))
                                coeff[0] += intSize;
                            else if( name.equals( "long") || name.equals( "J"))
                                coeff[0] += longSize;
View Full Code Here

Examples of java.lang.Class

    protected void read(ObjectInput in) throws IOException, ClassNotFoundException {
        byte b = in.readByte();
        if (b != CLASS) throw new IOException("Expected 'CLASS' byte " + CLASS + ", got: " + b);

        Class clazz = (Class) in.readObject();

        Object object;
        try {
            object = allocateInstance.invoke(unsafe, clazz);
        } catch (Exception e) {
            throw (IOException) new IOException("Cannot construct " + clazz.getName()).initCause(e);
        }

        while (b != DONE) {
            b = in.readByte();
            switch (b) {
                case FIELD: {
                    String fieldName = in.readUTF();
                    Object value = in.readObject();
                    Field field = null;
                    try {
                        field = clazz.getDeclaredField(fieldName);
                    } catch (NoSuchFieldException e) {
                        throw (IOException) new IOException("Cannot find field " + fieldName).initCause(e);
                    }
                    setValue(field, object, value);
                }
View Full Code Here

Examples of java.lang.Class

        this.object = object;
    }

    protected void write(ObjectOutput out) throws IOException {
        List<Class> classes = new ArrayList<Class>();
        Class c = object.getClass();
        while (c != null && !c.equals(Object.class)) {
            classes.add(c);
            c = c.getSuperclass();
        }

        for (Class clazz : classes) {
            out.writeByte(CLASS);
            out.writeObject(clazz);
View Full Code Here

Examples of java.lang.Class

            offset = (Long) objectFieldOffset.invoke(unsafe, field);
        } catch (Exception e) {
            throw new IllegalStateException("Failed getting offset for: field=" + field.getName() + "  class=" + field.getDeclaringClass().getName(), e);
        }

        Class type = field.getType();
        try {
            if (type.isPrimitive()) {
                if (type.equals(Integer.TYPE)) {
                    putInt.invoke(unsafe, object, offset, ((Integer) value).intValue());
                } else if (type.equals(Long.TYPE)) {
                    putLong.invoke(unsafe, object, offset, ((Long) value).longValue());
                } else if (type.equals(Short.TYPE)) {
                    putShort.invoke(unsafe, object, offset, ((Short) value).shortValue());
                } else if (type.equals(Character.TYPE)) {
                    putChar.invoke(unsafe, object, offset, ((Character) value).charValue());
                } else if (type.equals(Byte.TYPE)) {
                    putByte.invoke(unsafe, object, offset, ((Byte) value).byteValue());
                } else if (type.equals(Float.TYPE)) {
                    putFloat.invoke(unsafe, object, offset, ((Float) value).floatValue());
                } else if (type.equals(Double.TYPE)) {
                    putDouble.invoke(unsafe, object, offset, ((Double) value).doubleValue());
                } else if (type.equals(Boolean.TYPE)) {
                    putBoolean.invoke(unsafe, object, offset, ((Boolean) value).booleanValue());
                } else {
                    throw new IllegalStateException("Unknown primitive type: " + type.getName());
                }
            } else {
                putObject.invoke(unsafe, object, offset, value);
            }
        } catch (Exception e) {
View Full Code Here

Examples of java.lang.Class

         * @param className the name of the class for which a
         * validator class is to be found
         * @return the class which is to be used for validation
         **/
    Class getValidatorClass(final String className, String testPackage){
        Class c;
        final String cn = testPackage+className+"Test";
            try {
            c= Class.forName(cn);
        }
        catch (ClassNotFoundException cnfe2){
            c = GenericValidator.class;
        }
        _logger.log(Level.CONFIG, "validator using class \""+c.getName()+"\" to validate \""+cn+"\"");
        return c;
    }
View Full Code Here

Examples of java.lang.Class

        String message, ORBUtilSystemException wrapper)
    {
        SystemException sysEx = null;

        try {
            Class clazz = ORBClassLoader.loadClass(exClassName);
            if (message == null) {
                sysEx = (SystemException) clazz.newInstance();
            } else {
                Class[] types = { String.class };
                Constructor constructor = clazz.getConstructor(types);
                Object[] args = { message };
                sysEx = (SystemException)constructor.newInstance(args);
            }
        } catch (Exception someEx) {
            throw wrapper.badSystemExceptionInReply(
View Full Code Here

Examples of java.lang.Class

   protected void enableSubProp( String name ){
      int index = getSubPropNameIndex( name );
      if ( index < 0 ) {
         throw new RuntimeException("Attemtp to enable subProp: " + name + "\n\tname must be qualified\n");
      }
      Class tClass = BasicStringProperty.class;
      try {
         if ( index == MAX_LEN ) {
            setSubPropEval( index , evalMaxLenClosed );
            setSubPropMerge( index , Helpers . maxMethod );
         } else if ( index == MIN_LEN ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.