Esempio n. 1
0
  protected String write(T object, boolean writeData) {
    try {
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

      DesignContext dc = new DesignContext();
      if (writeData) {
        dc.setShouldWriteDataDelegate(DeclarativeTestBaseBase.ALWAYS_WRITE_DATA);
      }
      dc.setRootComponent(object);
      Design.write(dc, outputStream);
      return outputStream.toString("UTF-8");
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Esempio n. 2
0
 /**
  * Writes the component, given in the design context, in design format to the given output stream.
  * The design context is used for writing local ids and other information not available in the
  * component tree.
  *
  * @param designContext The DesignContext object specifying the component hierarchy and the local
  *     id values of the objects. If designContext.getRootComponent() is null, an empty design will
  *     be generated.
  * @param outputStream the output stream to write the design to. The design is always written as
  *     UTF-8
  * @throws IOException if writing fails
  */
 public static void write(DesignContext designContext, OutputStream outputStream)
     throws IOException {
   Document doc = createHtml(designContext);
   write(doc, outputStream);
 }
Esempio n. 3
0
 /**
  * Writes the given component tree in design format to the given output stream.
  *
  * @param component the root component of the component tree, null can be used for generating an
  *     empty design
  * @param outputStream the output stream to write the design to. The design is always written as
  *     UTF-8
  * @throws IOException
  */
 public static void write(Component component, OutputStream outputStream) throws IOException {
   DesignContext dc = new DesignContext();
   dc.setRootComponent(component);
   write(dc, outputStream);
 }
Esempio n. 4
0
  private ByteArrayOutputStream serializeDesign(DesignContext context) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Design.write(context, out);

    return out;
  }