Package rocket.generator.rebind.type

Examples of rocket.generator.rebind.type.Type


  @Override
  protected String getResourceName() {
    String fileName = null;

    while (true) {
      final Type returnType = this.getMethodReturnType();
      final GeneratorContext context = returnType.getGeneratorContext();

      if (returnType.equals(context.getBoolean())) {
        fileName = Constants.BOOLEAN_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getByte())) {
        fileName = Constants.BYTE_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getShort())) {
        fileName = Constants.SHORT_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getInt())) {
        fileName = Constants.INT_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getLong())) {
        fileName = Constants.LONG_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getFloat())) {
        fileName = Constants.FLOAT_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getDouble())) {
        fileName = Constants.DOUBLE_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getChar())) {
        fileName = Constants.CHAR_TEMPLATE;
        break;
      }
      if (returnType.equals(context.getVoid())) {
        fileName = Constants.VOID_TEMPLATE;
        break;
      }
      fileName = Constants.OBJECT_TEMPLATE;
      break;
View Full Code Here


    boolean blacklisted = false;

    // check black list...
    final Iterator<TypeMatcher> blackListers = this.getBlackList().iterator();
    final Type object = this.getGeneratorContext().getObject();

    while (blackListers.hasNext()) {
      final TypeMatcher matcher = blackListers.next();

      // scan entire type heirarchy just in case type or any super is
      // blacklisted.
      Type current = type;
      while (true) {
        if (matcher.matches(current)) {
          blacklisted = true;
          break;
        }

        current = current.getSuperType();
        if (null == current) {
          break;
        }
        // stop when we hit Object.
        if (object.equals(current)) {
View Full Code Here

    final Set<Type> allTypes = new HashSet<Type>();

    final GeneratorContext context = this.getGeneratorContext();
    final Iterator<Type> types = context.getObject().getSubTypes().iterator();
    while (types.hasNext()) {
      final Type type = types.next();
      if (this.isBlackListed(type)) {
        continue;
      }

      allTypes.add(type);
View Full Code Here

      final Iterator<Map.Entry<Type, Type>> iterator = sorted.entrySet().iterator();
      while (iterator.hasNext()) {
        final Map.Entry<Type, Type> entry = iterator.next();

        final Type type = entry.getKey();
        final Type type1 = entry.getValue();

        String message = type.getName();
        if (null != type1) {
          message = message + " = " + type1.getName();
        }
        context.debug(message);
      }
    }
  }
View Full Code Here

    final TreeSet<Type> types = new TreeSet<Type>(TypeComparator.INSTANCE);

    final Iterator<String> typeNames = type.getMetadataValues(annotation).iterator();
    while (typeNames.hasNext()) {
      final String typeName = typeNames.next();
      final Type listedType = context.findType(typeName);
      if (null == listedType) {
        this.throwUnableToFindAnnotatedType(typeName, type);
      }

      types.add(listedType);
      context.debug(listedType.getName());
    }

    context.unbranch();
    return types;
  }
View Full Code Here

  protected Set<Type> findSerializableTypes(final Set<Type> types, final Map<Type, Type> typesToReadersOrWriters) {
    final Set<Type> serializableTypes = new HashSet<Type>();

    final Iterator<Type> i = types.iterator();
    while (i.hasNext()) {
      final Type type = i.next();
      final Set<Type> newSerializableTypes = this.findSerializableTypes(type, typesToReadersOrWriters);
      serializableTypes.addAll(newSerializableTypes);
    }

    return serializableTypes;
View Full Code Here

    final GeneratorContext context = this.getGeneratorContext();
    context.branch();
    context.info("Finding all serializable types reachable from " + type);

    final Type map = this.getMap();
    final Type list = this.getList();
    final Type set = this.getSet();

    final ReachableTypesVisitor visitor = new ReachableTypesVisitor() {

      @Override
      protected boolean skipTypeThatImplementsInterface(final Type type, final Type interfacee) {
        return false == SerializationFactoryGenerator.this.isOrHasSerializableSubType(type);
      }

      @Override
      protected boolean skipArray(final Type array) {
        Checker.notNull("parameter:array", array);

        return false;
      }

      @Override
      protected boolean skipType(final Type type) {
        boolean skip = false;

        while (true) {
          // we dont want to visit the fields of $type we already have
          // a reader/writer.
          if (typesToReadersOrWriters.containsKey(type)) {
            skip = true;
            break;
          }
          if (SerializationFactoryGenerator.this.isOrHasSerializableSubType(type)) {
            skip = false;
            break;
          }
          skip = false;
          break;
        }

        return skip;
      }

      @Override
      protected void visitType(final Type type) {
        if (false == SerializationFactoryGenerator.this.isOrHasSerializableSubType(type)) {
          SerializationFactoryGenerator.this.throwEncounteredUnserializableType(type);
        }
        context.branch();
        context.debug(type.getName());
        super.visitType(type);
        context.unbranch();
      }

      @Override
      protected boolean skipSuperType(final Type superType) {
        return !SerializationFactoryGenerator.this.isOrHasSerializableSubType(superType);
      }

      @Override
      protected void visitSuperType(final Type superType) {
        context.branch();
        context.debug(superType.getName());
        super.visitSuperType(superType);
        context.unbranch();
      }

      @Override
      protected boolean skipSubType(final Type subType) {
        return !SerializationFactoryGenerator.this.isOrHasSerializableSubType(subType);
      }

      @Override
      protected void visitSubType(final Type subType) {
        context.branch();
        context.debug(subType.getName());
        super.visitSubType(subType);
        context.unbranch();
      }

      @Override
      protected void visitFields(final Type type) {
        if (false == typesToReadersOrWriters.containsKey(type)) {
          super.visitFields(type);
        }
      }

      /**
       * Skip transient or static fields.
       */
      @Override
      protected boolean skipField(final Field field) {
        Checker.notNull("parameter:field", field);

        return field.isStatic() || field.isTransient();
      }

      /**
       * This method includes special tests to ensure that list/set/map
       * element types are visited.
       *
       * @param field
       */
      @Override
      protected void visitField(final Field field) {
        Checker.notNull("parameter:field", field);

        context.branch();
        context.debug("Field: " + field.getName());

        while (true) {
          final Type fieldType = field.getType();

          if (field.isFinal()) {
            SerializationFactoryGenerator.this.throwFinalFieldEncountered(field);
          }

          if (list.equals(fieldType)) {
            this.processInterface(fieldType);

            final Type elementType = SerializationFactoryGenerator.this.getTypeFromAnnotation(field);
            context.debug(elementType + " (List)");
            this.visitType(elementType);
            break;
          }
          if (set.equals(fieldType)) {
            this.processInterface(fieldType);

            final Type elementType = SerializationFactoryGenerator.this.getTypeFromAnnotation(field);
            context.debug(elementType + " (Set)");
            this.visitType(elementType);
            break;
          }
          if (map.equals(fieldType)) {
            this.processInterface(fieldType);

            final Type keyType = SerializationFactoryGenerator.this.getTypeFromAnnotation(field, 0);
            final Type valueType = SerializationFactoryGenerator.this.getTypeFromAnnotation(field, 1);
            context.debug(keyType + " (Map key)");
            context.debug(valueType + " (Map value)");

            this.visitType(keyType);
            this.visitType(valueType);
View Full Code Here

    final List<String> values = field.getMetadataValues(SerializationConstants.CONTAINER_TYPE);
    if (values.size() < index) {
      throw new SerializationException("Unable to locate \"" + SerializationConstants.CONTAINER_TYPE + "\" on field " + field);
    }
    final String typeName = (String) values.get(index);
    final Type type = this.getGeneratorContext().findType(typeName);
    if (null == type) {
      throw new SerializationException("Unable to find type \"" + typeName + "\" which was taken from the annotation \""
          + SerializationConstants.CONTAINER_TYPE + "\" from field: " + field);
    }
    return type;
View Full Code Here

    final Iterator<Type> types = orderedSerializables.iterator();
    int skippedGeneratingCount = 0;
    final Set<Type> newReaders = new TreeSet<Type>(TypeComparator.INSTANCE);

    while (types.hasNext()) {
      final Type type = (Type) types.next();
      final Object reader = typesToReaders.get(type);
      if (null != reader) {
        skippedGeneratingCount++;
        continue;
      }

      context.branch();
      final NewConcreteType newReader = this.createObjectReader(type, typesToReaders);
      typesToReaders.put(type, newReader);

      context.branch();
      this.overrideObjectReaderNewInstanceMethod(type, newReader);

      if (false == type.isArray()) {
        this.overrideObjectReaderReadFieldsMethod(newReader, type);
        this.overrideObjectReaderReadMethod(newReader, type);
      }
      this.addSingletonField(newReader);
      context.unbranch();
View Full Code Here

    newConcreteType.setFinal(false);

    context.debug(newTypeName);

    // pick the right super type.
    Type objectReaderSuperType = null;

    while (true) {
      // if its an array simply extend ObjectArrayReader
      if (type.isArray()) {
        objectReaderSuperType = this.getArrayReader();
        break;
      }

      // if super type is object extend ObjectReaderImpl
      Type superType = type.getSuperType();
      if (superType.equals(context.getObject())) {
        objectReaderSuperType = this.getObjectReaderImpl();
        break;
      }

      // find the super types object reader and extend that...
View Full Code Here

TOP

Related Classes of rocket.generator.rebind.type.Type

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.