Package com.google.code.mojo.license

Examples of com.google.code.mojo.license.HeaderSection


        StringBuilder b = new StringBuilder();
        for( int i=0; i<textBetweenSections.size();++i) {
            String textBetween = textBetweenSections.get(i);
            b.append(textBetween);
            if( i < sectionsInOrder.size() ) {
                HeaderSection section = sectionsInOrder.get(i);
                String sectionValue = section.getDefaultValue();
                if( notEmpty(sectionValue)) {
                    String[] tokens = sectionValue.split(eol(unix));
                    for( int j=0;j<tokens.length; j++) {
                        if (j > 0) {
                            b.append(eol(unix));
View Full Code Here


            int indexEnd = index + section.getKey().length();

            for (Map.Entry<Integer, HeaderSection> entry : sectionsByIndex.entrySet()) {

                int existingIndexStart = entry.getKey();
                HeaderSection existingSection = entry.getValue();
                int existingIndexEnd = existingIndexStart + existingSection.getKey().length();

                if (existingIndexStart < indexEnd && index < existingIndexEnd)
                    throw new IllegalArgumentException(String.format(
                            "Existing section '%1$s' overlaps with new section '%2$s'", existingSection.getKey(),
                            section.getKey()));

                sectionsByIndex.put(index, section);
            }
View Full Code Here

        List<String> textBetweenSections = new ArrayList<String>();
        int currentIndex = 0;

        for (Map.Entry<Integer, HeaderSection> entry : sectionsByIndex.entrySet()) {
            int index = entry.getKey();
            HeaderSection section = entry.getValue();
            String textBetween = expectedHeaderText.substring(currentIndex, index);
            textBetweenSections.add(textBetween);
            currentIndex = index + section.getKey().length();
        }

        /**
         * Add the tail of the expected text
         */
 
View Full Code Here

            int index = potentialFileHeader.indexOf(expectedText, currentSearchFromIndex);
            if (index == -1)
                return false;

            if (currentTextSegmentIndex > 0) {
                HeaderSection section = sectionsInOrder.get(currentTextSegmentIndex - 1);
                String sectionValue = potentialFileHeader.substring(currentPotentialFileHeaderIndex, index);
                if (!ensureSectionMatch(headerDefinition, section, sectionValue))
                    return false;
            }
View Full Code Here

    }
   
    @Test
    public void testHeaderSections() throws MalformedURLException {
       
        HeaderSection section = new HeaderSection();
        section.setKey("COPYRIGHT_SECTION");
        section.setEnsureMatch("Copyright \\(C\\) \\d{4} .*");
        section.setDefaultValue("Copyright (C) 2011 http://code.google.com/p/maven-license-plugin/");
       
        HeaderSection[] sections = { section };
       
        Map<String, String> props = Collections.emptyMap();
        Header header = new Header(getClass().getResource("/test-header5.txt"), props, sections);
View Full Code Here

    }
   
    @Test
    public void testHeaderSectionsWithAmbiguousSeparation() throws MalformedURLException {
       
        HeaderSection sectionA = new HeaderSection();
        sectionA.setKey("COPYRIGHT_SECTION");
        sectionA.setDefaultValue("Copyright (C) 2011");
       
        HeaderSection sectionB = new HeaderSection();
        sectionB.setKey("NAME_SECTION");
        sectionB.setEnsureMatch("\\w+");
        sectionB.setDefaultValue("SomeGuy");
       
        HeaderSection[] sections = { sectionA, sectionB };
       
        Map<String, String> props = Collections.emptyMap();
        Header header = new Header(getClass().getResource("/test-header6.txt"), props, sections);
View Full Code Here

    }
   
    @Test
    public void testHeaderSectionsWithMultiLineMatch() throws MalformedURLException {
       
        HeaderSection section = new HeaderSection();
        section.setKey("COPYRIGHT_SECTION");
        section.setEnsureMatch("Copyright \\(C\\) \\d{4}\nName: .*");
        section.setMultiLineMatch(true);
        section.setDefaultValue("Copyright (C) 2011\nName: http://code.google.com/p/maven-license-plugin/");
       
        HeaderSection[] sections = { section };
       
        Map<String, String> props = Collections.emptyMap();
        Header header = new Header(getClass().getResource("/test-header5.txt"), props, sections);
View Full Code Here

TOP

Related Classes of com.google.code.mojo.license.HeaderSection

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.