Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make hierarch output format configuable #72

Closed
ritchieGitHub opened this issue Jan 15, 2016 · 1 comment
Closed

make hierarch output format configuable #72

ritchieGitHub opened this issue Jan 15, 2016 · 1 comment
Assignees
Labels
enhancement A new feature and/or an improved capability
Milestone

Comments

@ritchieGitHub
Copy link
Member

As discussed in #16 and #68 there is need to make the hierarch output more flexible.
I propose:

FitsFacory.setHierarchyFormat("123");

This means that the space between HIERARCH and the first key is filled with the characters "12" and the rest of the keywords separated by "3". So the last cha is used as key separator and the rest as preffix to the HIERARCH key.

@ritchieGitHub ritchieGitHub added the enhancement A new feature and/or an improved capability label Jan 15, 2016
@ritchieGitHub ritchieGitHub self-assigned this Jan 15, 2016
@ritchieGitHub ritchieGitHub added this to the 1.14.0 milestone Jan 15, 2016
@ritchieGitHub
Copy link
Member Author

I opted for the full dynamic solution now there is an interface IHierarchKeyFormatter that the user can implement and format the header keys to there wishes. There are tree default implementations, see the unit test:

    public void testHierarchAlternatives() throws HeaderCardException {
        FitsFactory.setUseHierarch(true);
        // not realy nessesary because the default:
        FitsFactory.setHierarchFormater(new StandardIHierarchKeyFormatter());
        HeaderCard headerCard = new HeaderCard("HIERARCH.TEST1.TEST2.TEST3.TEST4.TEST5.TEST6", "xy", null);
        assertEquals("HIERARCH.TEST1.TEST2.TEST3.TEST4.TEST5.TEST6", headerCard.getKey());
        assertEquals("HIERARCH TEST1 TEST2 TEST3 TEST4 TEST5 TEST6= 'xy'                              ", headerCard.toString());
        // now the formatter with all dots
        FitsFactory.setHierarchFormater(new BlanksDotHierarchKeyFormatter(1));
        assertEquals("HIERARCH.TEST1.TEST2.TEST3.TEST4.TEST5.TEST6", headerCard.getKey());
        assertEquals("HIERARCH TEST1.TEST2.TEST3.TEST4.TEST5.TEST6= 'xy'                              ", headerCard.toString());
        // now the formatter with first 2 blanks and then dots
        FitsFactory.setHierarchFormater(new BlanksDotHierarchKeyFormatter(2));
        assertEquals("HIERARCH.TEST1.TEST2.TEST3.TEST4.TEST5.TEST6", headerCard.getKey());
        assertEquals("HIERARCH  TEST1.TEST2.TEST3.TEST4.TEST5.TEST6= 'xy'                             ", headerCard.toString());

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature and/or an improved capability
Projects
None yet
Development

No branches or pull requests

1 participant