Search in sources :

Example 1 with NameCelebrations

use of com.alexstyl.specialdates.events.namedays.NameCelebrations in project Memento-Calendar by alexstyl.

the class GreeklishParserTest method alexandrosNamedayIsReturnedCorrectly.

@Test
public void alexandrosNamedayIsReturnedCorrectly() {
    NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFromJSONasSounds(namedayJSON);
    NameCelebrations dates = namedayBundle.getDatesFor("Αλέξανδρος");
    NameCelebrations datesGreeklish = namedayBundle.getDatesFor("Aleksandros");
    assertThatContainsSamedate(dates, datesGreeklish);
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Test(org.junit.Test)

Example 2 with NameCelebrations

use of com.alexstyl.specialdates.events.namedays.NameCelebrations in project Memento-Calendar by alexstyl.

the class CharacterNode method addDate.

@Override
public void addDate(String name, Date date) {
    Index index = new Index(name.length());
    if (index.hasNotStarted()) {
        if (dates == null) {
            dates = new NameCelebrations(name);
        }
    }
    index.stepUp();
    addDateInternal(index, name, date);
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) Index(com.alexstyl.gsc.Index)

Example 3 with NameCelebrations

use of com.alexstyl.specialdates.events.namedays.NameCelebrations in project Memento-Calendar by alexstyl.

the class CharacterNode method addDateInternal.

private void addDateInternal(Index index, String word, Date date) {
    Character s = null;
    if (!index.hasEnded()) {
        s = word.charAt(index.intValue());
        index.stepUp();
        if (index.intValue() == word.length()) {
            index.end();
        }
    }
    if (s == null) {
        if (dates == null) {
            dates = new NameCelebrations(word);
        }
        dates.addDate(date);
    } else {
        CharacterNode theNode = null;
        Collator collator = getCollator();
        for (CharacterNode node : nodes) {
            if (collator.compare(node.keySound.toString(), s.toString()) == 0) {
                theNode = node;
                break;
            }
        }
        if (theNode == null) {
            theNode = new CharacterNode(s);
            nodes.add(theNode);
        }
        theNode.addDateInternal(index, word, date);
    }
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) Collator(java.text.Collator)

Example 4 with NameCelebrations

use of com.alexstyl.specialdates.events.namedays.NameCelebrations in project Memento-Calendar by alexstyl.

the class CharacterNode method getDatesInternal.

private NameCelebrations getDatesInternal(Index index, String name) {
    Character s = null;
    if (!index.hasEnded()) {
        s = name.charAt(index.intValue());
        index.stepUp();
        if (index.intValue() >= name.length()) {
            index.end();
        }
    }
    if (s == null) {
        return getDates();
    } else {
        Collator collator = getCollator();
        for (CharacterNode node : nodes) {
            if (collator.compare(node.keySound.toString(), s.toString()) == 0) {
                int currentIndex = index.intValue();
                NameCelebrations e = node.getDatesInternal(index, name);
                if (e != null) {
                    return e;
                }
                index.setTo(currentIndex);
            }
        }
        return new NameCelebrations(name);
    }
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) Collator(java.text.Collator)

Example 5 with NameCelebrations

use of com.alexstyl.specialdates.events.namedays.NameCelebrations in project Memento-Calendar by alexstyl.

the class NamedayJSONParserTest method amaliaNamedayIsReturnedCorrectly.

@Test
public void amaliaNamedayIsReturnedCorrectly() {
    NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFrom(namedayJSON);
    NameCelebrations dates = namedayBundle.getDatesFor("Αμαλία");
    assertThatContainsDate(dates, Date.Companion.on(10, JULY));
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Test(org.junit.Test)

Aggregations

NameCelebrations (com.alexstyl.specialdates.events.namedays.NameCelebrations)12 Test (org.junit.Test)8 NamedayBundle (com.alexstyl.specialdates.events.namedays.NamedayBundle)6 Collator (java.text.Collator)2 Index (com.alexstyl.gsc.Index)1 Date (com.alexstyl.specialdates.date.Date)1 Dates (com.alexstyl.specialdates.date.Dates)1