This repository has been archived by the owner on Nov 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated bypass marker processor factory
- Loading branch information
Joel Håkansson
committed
Aug 28, 2013
1 parent
c4a0916
commit 7193d86
Showing
7 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...lator/src/META-INF/services/org.daisy.dotify.translator.attributes.MarkerProcessorFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
org.daisy.dotify.impl.translator.sv_SE.SwedishMarkerProcessorFactory | ||
org.daisy.dotify.impl.translator.sv_SE.SwedishMarkerProcessorFactory | ||
org.daisy.dotify.impl.translator.DefaultBypassMarkerProcessorFactory |
30 changes: 30 additions & 0 deletions
30
...yTranslator/src/org/daisy/dotify/impl/translator/DefaultBypassMarkerProcessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.daisy.dotify.impl.translator; | ||
|
||
import org.daisy.dotify.text.FilterLocale; | ||
import org.daisy.dotify.translator.BrailleTranslatorFactory; | ||
import org.daisy.dotify.translator.UnsupportedSpecificationException; | ||
import org.daisy.dotify.translator.attributes.DefaultMarkerProcessor; | ||
import org.daisy.dotify.translator.attributes.Marker; | ||
import org.daisy.dotify.translator.attributes.MarkerProcessor; | ||
import org.daisy.dotify.translator.attributes.MarkerProcessorFactory; | ||
import org.daisy.dotify.translator.attributes.SimpleMarkerDictionary; | ||
import org.daisy.dotify.translator.attributes.StyleConstants; | ||
|
||
public class DefaultBypassMarkerProcessorFactory implements | ||
MarkerProcessorFactory { | ||
|
||
public boolean supportsSpecification(FilterLocale locale, String mode) { | ||
return mode.equals(BrailleTranslatorFactory.MODE_BYPASS); | ||
} | ||
|
||
public MarkerProcessor newMarkerProcessor(FilterLocale locale, String mode) throws UnsupportedSpecificationException { | ||
if (mode.equals(BrailleTranslatorFactory.MODE_BYPASS)) { | ||
SimpleMarkerDictionary dd = new SimpleMarkerDictionary(new Marker("* ", "")); | ||
|
||
DefaultMarkerProcessor sap = new DefaultMarkerProcessor.Builder().addDictionary(StyleConstants.DD, dd).build(); | ||
return sap; | ||
} | ||
throw new UnsupportedSpecificationException("Factory does not support " + locale + "/" + mode); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...slator/test/org/daisy/dotify/impl/translator/DefaultBypassMarkerProcessorFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.daisy.dotify.impl.translator; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.daisy.dotify.text.FilterLocale; | ||
import org.daisy.dotify.translator.BrailleTranslatorFactory; | ||
import org.daisy.dotify.translator.UnsupportedSpecificationException; | ||
import org.daisy.dotify.translator.attributes.DefaultTextAttribute; | ||
import org.daisy.dotify.translator.attributes.MarkerProcessor; | ||
import org.junit.Test; | ||
|
||
public class DefaultBypassMarkerProcessorFactoryTest { | ||
private final MarkerProcessor tp; | ||
|
||
public DefaultBypassMarkerProcessorFactoryTest() throws UnsupportedSpecificationException { | ||
tp = new DefaultBypassMarkerProcessorFactory().newMarkerProcessor(FilterLocale.parse("sv-se"), BrailleTranslatorFactory.MODE_BYPASS); | ||
} | ||
|
||
@Test | ||
public void testDD_Text() { | ||
String text = "3rd"; | ||
DefaultTextAttribute.Builder atts = new DefaultTextAttribute.Builder(); | ||
atts.add(new DefaultTextAttribute.Builder("dd").build(3)); | ||
String actual = tp.processAttributes(atts.build(3), text); | ||
assertEquals("", "* 3rd", actual); | ||
} | ||
|
||
@Test | ||
public void testEm_Text() { | ||
String text = "3rd"; | ||
DefaultTextAttribute.Builder atts = new DefaultTextAttribute.Builder(); | ||
atts.add(new DefaultTextAttribute.Builder("em").build(3)); | ||
String actual = tp.processAttributes(atts.build(3), text); | ||
assertEquals("", "3rd", actual); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
DotifyTranslator/test/org/daisy/dotify/translator/attributes/MarkerProcessorFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.daisy.dotify.translator.attributes; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.daisy.dotify.text.FilterLocale; | ||
import org.daisy.dotify.translator.BrailleTranslatorFactory; | ||
import org.daisy.dotify.translator.UnsupportedSpecificationException; | ||
import org.junit.Test; | ||
|
||
public class MarkerProcessorFactoryTest { | ||
|
||
@Test | ||
public void testFactory() throws UnsupportedSpecificationException { | ||
MarkerProcessor m = MarkerProcessorFactoryMaker.newInstance().newMarkerProcessor(FilterLocale.parse("en-US"), BrailleTranslatorFactory.MODE_BYPASS); | ||
assertNotNull("Factory exists", m); | ||
} | ||
|
||
@Test | ||
public void testSwedishBrailleFactory() throws UnsupportedSpecificationException { | ||
MarkerProcessor m = MarkerProcessorFactoryMaker.newInstance().newMarkerProcessor(FilterLocale.parse("sv-SE"), BrailleTranslatorFactory.MODE_UNCONTRACTED); | ||
assertNotNull("Factory exists", m); | ||
} | ||
|
||
@Test | ||
public void testSwedishTextFactory() throws UnsupportedSpecificationException { | ||
MarkerProcessor m = MarkerProcessorFactoryMaker.newInstance().newMarkerProcessor(FilterLocale.parse("sv-SE"), BrailleTranslatorFactory.MODE_BYPASS); | ||
assertNotNull("Factory exists", m); | ||
} | ||
|
||
} |