Examples of CharacterSequence


Examples of org.hybridlabs.source.beautifier.CharacterSequence

    }

    public void testSample03Formatted() throws Exception {
        beautifier.setFormat(true);

        CharacterSequence sequence = new CharacterSequence(loadTestFile("Sample03.java_input"));
        beautifier.beautify(sequence);

        CharacterSequence expectedOutput = new CharacterSequence(loadTestFile("Sample03.java_output_formatted"));
        compare(expectedOutput, sequence);
    }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

   */
  public void beautify(File sourceFile, File targetFile)
      throws FileNotFoundException, IOException {
    StringBuffer buffer = FileHelper.loadStringBuffer(sourceFile);

    CharacterSequence sequence = new CharacterSequence(buffer);
    beautify(sequence);

    String targetPath = sourceFile.getAbsolutePath();
    if (targetFile != null) {
      targetPath = targetFile.getAbsolutePath();
    }

    FileWriter writer = new FileWriter(new File(targetPath));
    writer.write(sequence.toString());
    writer.close();
  }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

        if (useConventionFile) {
            beautifier.setConventionFilePath("src/test/resources/test-convention.xml");
        }

        CharacterSequence sequence = new CharacterSequence(loadTestFile("Sample" + sampleIndex + ".java_input"));
        beautifier.beautify(sequence);

        CharacterSequence expectedOutput = new CharacterSequence(loadTestFile("Sample" + sampleIndex + ".java_output"));
        compare(expectedOutput, sequence);
    }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

      CharSequence charSequence = null;

      charSequence = CompatibilityHelper.getBuffer(info);

      CharacterSequence sequence = new CharacterSequence(charSequence);
      beautify(sequence);
      if (sequence.getStringBuffer() != null
          && sequence.getStringBuffer().length() > 0) {
        // info.setBuffer(sequence);
        // NOTE: resolving compatibility issue 4.1/4.2
        CompatibilityHelper.setBuffer(info, sequence);
      }
    }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

    for (int i = 0; i < listSize; i++) {
      File sourceFile = (File) sourceFiles.get(i);
      LOG.info(message + sourceFile.getName() + " under "
          + sourceFile.getParent());

      CharacterSequence sequence = new CharacterSequence(
          FileHelper.loadStringBuffer(sourceFile));
      String original = sequence.getString();

      try {
        beautifier.beautify(sequence);
        // Only overwrite the file if the beautifier changes it, or if a
        // different directory
        // Sometimes Jalopy throws an error and returns a zero length
        // file.
        if (sequence.length() > 1
            && (!original.equals(sequence.getString()))) {
          File targetFile = new File((manager.getTargetDirectory(
              sourceFile, sourceRootDirectory,
              targetRootDirectory)), sourceFile.getName());
          // File targetDirectory = new
          // File((manager.getTargetDirectory(
          // sourceFile, targetRootDirectory)), sourceFile.getName());
          FileOutputStream outputSource = new FileOutputStream(
              targetFile);
          outputSource.write(sequence.getString().getBytes());
          outputSource.flush();
          outputSource.close();
        }
      } catch (RuntimeException e) {
        LOG.error("Exception formatting file: " + sourceFile.getName(),
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

    // Unexpected char '<'
    beautifier.setFormat(jalopy);

    LOG.info("Formatting file: " + sourceFile.getName());

    CharacterSequence sequence = new CharacterSequence(
        FileHelper.loadStringBuffer(sourceFile));

    try {
      beautifier.beautify(sequence);
      // Only overwrite the file if the beautifier changes it, or if a
      // different directory
      // Sometimes Jalopy throws an error and returns a zero length file.
      if (sequence.length() > 1) {
        File targetFile = null;
        if (targetRootDirectory == null
            || "".equals(targetRootDirectory)) {
          targetFile = sourceFile;
        } else {
          targetFile = new File(targetRootDirectory,
              sourceFile.getName());
          targetFile = new File((manager.getTargetDirectory(
              sourceFile, sourceFile.getParent(),
              targetRootDirectory)), sourceFile.getName());
        }
        // File targetDirectory = new File((manager.getTargetDirectory(
        // sourceFile, targetRootDirectory)), sourceFile.getName());
        FileOutputStream outputSource = new FileOutputStream(targetFile);
        outputSource.write(sequence.getString().getBytes());
        outputSource.flush();
        outputSource.close();
      }
    } catch (RuntimeException e) {
      LOG.error("Exception formatting file: " + sourceFile.getName(), e);
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

    public void testSampleEntityBean() throws Exception {
        JavaImportBeautifierImpl beautifier = new JavaImportBeautifierImpl();
        beautifier.setFormat(true);
        beautifier.setOrganizeImports(true);

        CharacterSequence sequence = new CharacterSequence(loadTestFile("Documentation_Sample1.java_input"));
        beautifier.beautify(sequence);

        CharacterSequence expectedOutput = new CharacterSequence(loadTestFile("Documentation_Sample1.java_output"));
        compare(expectedOutput, sequence);

    }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

        PostProcessor postProcessor = new JavaImportBeautifier();
        Properties p = System.getProperties();
        File file = new File("src/test/resources/Sample0.java");
        FileHandle fh = new FileHandleImpl(null, file);

        fh.setBuffer(new CharacterSequence(loadTestFile("Sample01.java_input")));

        postProcessor.beforeWriteAndClose(fh);

        assertNotNull(fh.getBuffer());
    }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

    public void testSample1() throws Exception {
        testIndexedSample("01", false, false);
    }

    public void testSample1Formatted() throws Exception {
        CharacterSequence sequence = new CharacterSequence(loadTestFile("Sample01.java_input"));
        beautifier.beautify(sequence);

        CharacterSequence expectedOutput = new CharacterSequence(loadTestFile("Sample01.java_formatted_output"));
        compare(expectedOutput, sequence);
    }
View Full Code Here

Examples of org.hybridlabs.source.beautifier.CharacterSequence

    }

    public void testSample03Formatted() throws Exception {
        beautifier.setFormat(true);

        CharacterSequence sequence = new CharacterSequence(loadTestFile("Sample03.java_input"));
        beautifier.beautify(sequence);

        CharacterSequence expectedOutput = new CharacterSequence(loadTestFile("Sample03.java_output_formatted"));
        compare(expectedOutput, sequence);
    }
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.