Examples of GeneratorContext


Examples of org.drools.workbench.models.commons.backend.rule.GeneratorContext

        @Override
        public void postGenerateNestedConnector( GeneratorContext gctx ) {
            if ( gctx.getVarsInScope().size() > 0 ) {
                buf.append( "@end{}" );
            } else {
                GeneratorContext parentContext = gctx.getParent();
                if ( parentContext != null ) {
                    Set<String> parentVarsInScope = new HashSet<String>( parentContext.getVarsInScope() );
                    parentVarsInScope.removeAll( gctx.getVarsInScope() );
                    if ( parentVarsInScope.size() > 0 ) {
                        buf.append( "@end{}" );
                    }
                }
View Full Code Here

Examples of org.drools.workbench.models.commons.backend.rule.GeneratorContext

                for ( String var : gctx.getVarsInScope() ) {
                    buf.append( var + " != empty || " );
                }
                buf.delete( buf.length() - 4, buf.length() );

                GeneratorContext parentContext = gctx.getParent();
                if ( parentContext != null ) {
                    Set<String> parentVarsInScope = new HashSet<String>( parentContext.getVarsInScope() );
                    parentVarsInScope.removeAll( gctx.getVarsInScope() );
                    if ( parentVarsInScope.size() > 0 ) {
                        buf.append( ") && !(" );
                        for ( String var : parentVarsInScope ) {
                            buf.append( var + " == empty && " );
                        }
                        buf.delete( buf.length() - 4, buf.length() );
                    }
                }
                buf.append( ") || hasNonTemplateOutput" ).append( gctx.getDepth() + "_" + gctx.getOffset() ).append( "}" );
            } else {
                GeneratorContext parentContext = gctx.getParent();
                if ( parentContext != null ) {
                    Set<String> parentVarsInScope = new HashSet<String>( parentContext.getVarsInScope() );
                    parentVarsInScope.removeAll( gctx.getVarsInScope() );
                    if ( parentVarsInScope.size() > 0 ) {
                        buf.append( "@if{!(" );
                        for ( String var : parentVarsInScope ) {
                            buf.append( var + " == empty || " );
View Full Code Here

Examples of org.drools.workbench.models.commons.backend.rule.GeneratorContext

        @Override
        public void postGenerateNestedConnector( GeneratorContext gctx ) {
            if ( gctx.getVarsInScope().size() > 0 ) {
                buf.append( "@end{}" );
            } else {
                GeneratorContext parentContext = gctx.getParent();
                if ( parentContext != null ) {
                    Set<String> parentVarsInScope = new HashSet<String>( parentContext.getVarsInScope() );
                    parentVarsInScope.removeAll( gctx.getVarsInScope() );
                    if ( parentVarsInScope.size() > 0 ) {
                        buf.append( "@end{}" );
                    }
                }
View Full Code Here

Examples of org.openbp.cockpit.generator.GeneratorContext

    // Get the dialog title from the wizard resource
    String title = getPageResourceString(null, "title");
    dialog.setTitle(title);

    // Initializes the subect.
    context = new GeneratorContext();
    if (!isNewItem)
    {
      // Save the original item for name uniqueness check reference and status restoration
      context.setOriginalItem(item);
View Full Code Here

Examples of rocket.generator.rebind.GeneratorContext

  protected String getResourceName() {
    String fileName = null;

    while (true) {
      final MethodParameter parameter = this.getParameter();
      final GeneratorContext context = parameter.getGeneratorContext();
      final Type type = parameter.getType();
      if (type.equals(context.getBoolean())) {
        fileName = Constants.BOOLEAN;
        break;
      }
      if (type.equals(context.getByte())) {
        fileName = Constants.BYTE;
        break;
      }
      if (type.equals(context.getShort())) {
        fileName = Constants.SHORT;
        break;
      }
      if (type.equals(context.getInt())) {
        fileName = Constants.INT;
        break;
      }
      if (type.equals(context.getLong())) {
        fileName = Constants.LONG;
        break;
      }
      if (type.equals(context.getFloat())) {
        fileName = Constants.FLOAT;
        break;
      }
      if (type.equals(context.getDouble())) {
        fileName = Constants.DOUBLE;
        break;
      }
      if (type.equals(context.getChar())) {
        fileName = Constants.CHAR;
        break;
      }
      fileName = Constants.OBJECT;
      break;
View Full Code Here

Examples of rocket.generator.rebind.GeneratorContext

    // generate readers and then writers
    this.createObjectReaders(serializableReadableTypes, typesToReaders);
    this.createObjectWriters(serializableWritableTypes, typesToWriters);

    // nows the time to create the SerializationFactory
    final GeneratorContext context = this.getGeneratorContext();
    context.branch();
    final NewConcreteType serializationFactory = this.createSerializableFactory(newTypeName);

    this.overrideSerializationFactoryGetObjectReader(serializationFactory, typesToReaders);
    this.overrideSerializationFactoryGetObjectWriter(serializationFactory, typesToWriters);
    context.unbranch();

    return serializationFactory;

  }
View Full Code Here

Examples of rocket.generator.rebind.GeneratorContext

   * expressions.
   *
   * @return A set containing all blacklisted packages.
   */
  protected Set<TypeMatcher> loadBlackLists() {
    final GeneratorContext context = this.getGeneratorContext();
    context.branch();
    context.info("Attempting to load and merge all blacklists (unsorted).");

    final Set<TypeMatcher> blackLists = new HashSet<TypeMatcher>();

    final SubTypesVisitor packageVisitor = new SubTypesVisitor() {

      @Override
      protected boolean visit(final Type type) {
        final Package packagee = type.getPackage();
        if (false == this.packages.contains(packagee)) {
          this.packages.add(packagee);

          final Set<TypeMatcher> loaded = SerializationFactoryGenerator.this.loadBlackListFromPackage(packagee);
          blackLists.addAll(loaded);
        }
        return false;
      }

      @Override
      protected boolean skipInitialType() {
        return false;
      }

      Set<Package> packages = new HashSet<Package>();
    };
    packageVisitor.start(context.getObject());

    context.unbranch();

    return blackLists;
  }
View Full Code Here

Examples of rocket.generator.rebind.GeneratorContext

   * @return A set of types or an empty set if the black list was not found.
   */
  protected Set<TypeMatcher> loadBlackListFromPackage(final Package packagee) {
    Checker.notNull("parameter:package", packagee);

    final GeneratorContext context = this.getGeneratorContext();
    context.delayedBranch();
    context.debug(packagee.getName());

    final Set<TypeMatcher> expressions = new HashSet<TypeMatcher>();

    final String fileName = this.getResourceName(packagee, SerializationConstants.BLACKLIST_FILENAME);
    InputStream inputStream = null;

    while (true) {
      try {
        inputStream = this.getClass().getResourceAsStream(fileName);
        if (null == inputStream) {
          break;
        }
        // context.debug(fileName);

        // use a BufferedReader to read a line at a time skipping
        // comments and empty lines.
        final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

        while (true) {
          final String line = reader.readLine();
          // eof reached...
          if (null == line) {
            break;
          }

          // skip empty / comment lines...
          final String typeName = line.trim();
          if (Tester.isNullOrEmpty(typeName) || typeName.startsWith("#")) {
            continue;
          }
          context.debug(line);

          final TypeMatcher typeNameMatcher = TypeMatcherFactory.createTypeNameMatcher(typeName);
          expressions.add(typeNameMatcher);
        }

        break;

      } catch (final RuntimeException caught) {
        throw caught;
      } catch (final Exception caught) {
        throw new SerializationFactoryGeneratorException("Failed to load black list, message: " + caught.getMessage(), caught);
      } finally {
        InputOutput.closeIfNecessary(inputStream);
      }
    }

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

Examples of rocket.generator.rebind.GeneratorContext

   * @return
   */
  protected Set<Type> getAllSerializableTypes() {
    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);
    }

    // TODO hack need to add proper support for arrays
    allTypes.add(context.getType("boolean[]"));
    allTypes.add(context.getType("byte[]"));
    allTypes.add(context.getType("short[]"));
    allTypes.add(context.getType("int[]"));
    allTypes.add(context.getType("long[]"));
    allTypes.add(context.getType("float[]"));
    allTypes.add(context.getType("double[]"));
    allTypes.add(context.getType("char[]"));
    return allTypes;
  }
View Full Code Here

Examples of rocket.generator.rebind.GeneratorContext

   * @return
   */
  protected Map<Type, Type> findAllReaders(final Set<Type> types) {
    Checker.notNull("parameter:types", types);

    final GeneratorContext context = this.getGeneratorContext();
    context.branch();
    context.info("Finding existing ObjectReaders...");

    final ObjectReaderFinder finder = new ObjectReaderFinder() {
      @Override
      protected Type getImplementingInterface() {
        return SerializationFactoryGenerator.this.getObjectReader();
      }

      @Override
      protected boolean shouldBeSerialized(final Type type) {
        return SerializationFactoryGenerator.this.isOrHasSerializableSubType(type);
      }
    };

    final Map<Type, Type> typesToReaders = finder.build(types);

    this.logMapping(typesToReaders);

    context.unbranch();

    return typesToReaders;
  }
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.