1.1 --- a/.hgignore Mon Jul 08 23:38:22 2013 +0200
1.2 +++ b/.hgignore Tue Jul 09 18:59:07 2013 +0200
1.3 @@ -1,4 +1,5 @@
1.4 temp/*
1.5 +delivery/*
1.6 data/schemas.xml
1.7 java/dictionary-generator/nbproject/private
1.8 java/dictionary-generator/build/*
2.1 --- a/data/dictionary.xml Mon Jul 08 23:38:22 2013 +0200
2.2 +++ b/data/dictionary.xml Tue Jul 09 18:59:07 2013 +0200
2.3 @@ -32,7 +32,7 @@
2.4 </tags>
2.5
2.6 <concept>
2.7 - <term abbreviation="MVNO" completeForm=" mobile virtual network operator" language="en"/>
2.8 + <term abbreviation="MVNO" completeForm="mobile virtual network operator" language="en"/>
2.9 <explanation language="en"><text></text></explanation>
2.10 </concept>
2.11 <concept>
2.12 @@ -1259,7 +1259,7 @@
2.13 <tag>computer</tag>
2.14 </concept>
2.15 <concept>
2.16 - <term abbreviation="FUP" completeForm="fair user policy" language="en"/>
2.17 + <term abbreviation="FUP" completeForm="fair usage policy" language="en"/>
2.18 <explanation language="en"><text></text></explanation>
2.19 </concept>
2.20 <concept>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/java/dictionary-generator/concept.xsl Tue Jul 09 18:59:07 2013 +0200
3.3 @@ -0,0 +1,72 @@
3.4 +<?xml version="1.0" encoding="UTF-8"?>
3.5 +<xsl:stylesheet version="1.0"
3.6 + xmlns="http://www.w3.org/1999/xhtml"
3.7 + xmlns:h="http://www.w3.org/1999/xhtml"
3.8 + xmlns:d="https://telco.frantovo.cz/xmlns/dictionary"
3.9 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3.10 + xmlns:fn="http://www.w3.org/2005/xpath-functions"
3.11 + xmlns:xs="http://www.w3.org/2001/XMLSchema"
3.12 + exclude-result-prefixes="fn h d xs">
3.13 + <xsl:output
3.14 + method="xml"
3.15 + indent="no"
3.16 + encoding="UTF-8"
3.17 + omit-xml-declaration="yes"/>
3.18 +
3.19 + <xsl:param name="tags"/>
3.20 +
3.21 + <xsl:template match="d:concept">
3.22 + <div>
3.23 + <!--
3.24 + This template should be shortened,
3.25 + if used for dictionaries containing many words.
3.26 + -->
3.27 + <style type="text/css">
3.28 + table {
3.29 + border-collapse:collapse;
3.30 + box-shadow: 3px 3px 3px grey;
3.31 + margin-top: 10px;
3.32 + margin-bottom: 10px;
3.33 + }
3.34 + td, th {
3.35 + border: 1px solid black;
3.36 + padding-top: 4px;
3.37 + padding-bottom: 4px;
3.38 + padding-left: 6px;
3.39 + padding-right: 6px;
3.40 + font-weight: normal;
3.41 + }
3.42 + p.tags {
3.43 + font-size: 80%;
3.44 + }
3.45 + </style>
3.46 + <table>
3.47 + <tbody>
3.48 + <xsl:for-each select="d:term">
3.49 + <tr>
3.50 + <td><xsl:value-of select="@abbreviation"/></td>
3.51 + <td><xsl:value-of select="@completeForm"/></td>
3.52 + </tr>
3.53 + </xsl:for-each>
3.54 + </tbody>
3.55 + </table>
3.56 +
3.57 + <p><xsl:apply-templates select="d:explanation"/></p>
3.58 +
3.59 + <xsl:if test="d:tag">
3.60 + <p class="tags">
3.61 + <xsl:text>Tags: </xsl:text>
3.62 + <xsl:for-each select="d:tag">
3.63 + <xsl:variable name="tagID" select="text()"/>
3.64 + <xsl:apply-templates/>
3.65 + <!--
3.66 + <xsl:value-of select="$tags/d:tag[@id=$tagID]/@name"/>
3.67 + -->
3.68 + <xsl:if test="not(position() = last())"><xsl:text>, </xsl:text></xsl:if>
3.69 + </xsl:for-each>
3.70 + </p>
3.71 + </xsl:if>
3.72 + </div>
3.73 + </xsl:template>
3.74 +
3.75 +</xsl:stylesheet>
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/DocumentNamespaceContext.java Tue Jul 09 18:59:07 2013 +0200
4.3 @@ -0,0 +1,58 @@
4.4 +/**
4.5 + * Free Telco Dictionary
4.6 + * Copyright © 2013 František Kučera (frantovo.cz)
4.7 + *
4.8 + * This program is free software: you can redistribute it and/or modify
4.9 + * it under the terms of the GNU General Public License as published by
4.10 + * the Free Software Foundation, either version 3 of the License, or
4.11 + * (at your option) any later version.
4.12 + *
4.13 + * This program is distributed in the hope that it will be useful,
4.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.16 + * GNU General Public License for more details.
4.17 + *
4.18 + * You should have received a copy of the GNU General Public License
4.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
4.20 + */
4.21 +package cz.frantovo.telco.dictionary;
4.22 +
4.23 +import java.util.Iterator;
4.24 +import javax.xml.XMLConstants;
4.25 +import javax.xml.namespace.NamespaceContext;
4.26 +import org.w3c.dom.Document;
4.27 +
4.28 +/**
4.29 + *
4.30 + * @author Ing. František Kučera (frantovo.cz)
4.31 + */
4.32 +public class DocumentNamespaceContext implements NamespaceContext {
4.33 +
4.34 + private Document document;
4.35 +
4.36 + public DocumentNamespaceContext(Document document) {
4.37 + this.document = document;
4.38 + }
4.39 +
4.40 + @Override
4.41 + public String getNamespaceURI(String prefix) {
4.42 + if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
4.43 + return document.lookupNamespaceURI(null);
4.44 + } else {
4.45 + return document.lookupNamespaceURI(prefix);
4.46 + }
4.47 + }
4.48 +
4.49 + @Override
4.50 + public String getPrefix(String xmlns) {
4.51 + return document.lookupPrefix(xmlns);
4.52 + }
4.53 +
4.54 + /**
4.55 + * TODO: support multiple prefixes
4.56 + */
4.57 + @Override
4.58 + public Iterator getPrefixes(String xmlns) {
4.59 + return new OneItemIterator(getPrefix(xmlns));
4.60 + }
4.61 +}
4.62 \ No newline at end of file
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/Functions.java Tue Jul 09 18:59:07 2013 +0200
5.3 @@ -0,0 +1,92 @@
5.4 +/**
5.5 + * Free Telco Dictionary
5.6 + * Copyright © 2013 František Kučera (frantovo.cz)
5.7 + *
5.8 + * This program is free software: you can redistribute it and/or modify
5.9 + * it under the terms of the GNU General Public License as published by
5.10 + * the Free Software Foundation, either version 3 of the License, or
5.11 + * (at your option) any later version.
5.12 + *
5.13 + * This program is distributed in the hope that it will be useful,
5.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.16 + * GNU General Public License for more details.
5.17 + *
5.18 + * You should have received a copy of the GNU General Public License
5.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
5.20 + */
5.21 +package cz.frantovo.telco.dictionary;
5.22 +
5.23 +import java.io.Closeable;
5.24 +import java.io.IOException;
5.25 +import java.util.HashSet;
5.26 +import java.util.Iterator;
5.27 +import java.util.Map;
5.28 +import java.util.Map.Entry;
5.29 +import java.util.Set;
5.30 +import java.util.logging.Level;
5.31 +import java.util.logging.Logger;
5.32 +import org.w3c.dom.Node;
5.33 +import org.w3c.dom.NodeList;
5.34 +
5.35 +/**
5.36 + *
5.37 + * @author Ing. František Kučera (frantovo.cz)
5.38 + */
5.39 +public class Functions {
5.40 +
5.41 + private static final Logger log = Logger.getLogger(Functions.class.getName());
5.42 +
5.43 + public static Iterable<Node> nodeIterable(final NodeList list) {
5.44 + return new Iterable<Node>() {
5.45 + @Override
5.46 + public Iterator<Node> iterator() {
5.47 + return new Iterator<Node>() {
5.48 + int position;
5.49 +
5.50 + @Override
5.51 + public boolean hasNext() {
5.52 + return position < list.getLength();
5.53 + }
5.54 +
5.55 + @Override
5.56 + public Node next() {
5.57 + return list.item(position++);
5.58 + }
5.59 +
5.60 + @Override
5.61 + public void remove() {
5.62 + throw new UnsupportedOperationException("remove not supported");
5.63 + }
5.64 + };
5.65 + }
5.66 + };
5.67 + }
5.68 +
5.69 + public static void close(Closeable c) {
5.70 + try {
5.71 + c.close();
5.72 + } catch (Exception e) {
5.73 + log.log(Level.WARNING, "closing of " + c + " has failed", e);
5.74 + }
5.75 + }
5.76 +
5.77 + public static boolean equalz(Object a, Object b) {
5.78 + return a == null ? b == null : a.equals(b);
5.79 + }
5.80 +
5.81 + public static <K, V> Set<K> getKeysForValue(Map<K, V> map, V value) {
5.82 + Set<K> keysFound = new HashSet<>();
5.83 +
5.84 + for (Entry<K, V> entry : map.entrySet()) {
5.85 + if (equalz(value, entry.getValue())) {
5.86 + keysFound.add(entry.getKey());
5.87 + }
5.88 + }
5.89 +
5.90 + return keysFound;
5.91 + }
5.92 +
5.93 + private Functions() {
5.94 + }
5.95 +}
6.1 --- a/java/dictionary-generator/src/cz/frantovo/telco/dictionary/Generator.java Mon Jul 08 23:38:22 2013 +0200
6.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/Generator.java Tue Jul 09 18:59:07 2013 +0200
6.3 @@ -17,13 +17,189 @@
6.4 */
6.5 package cz.frantovo.telco.dictionary;
6.6
6.7 +import static cz.frantovo.telco.dictionary.Xmlns.*;
6.8 +import static cz.frantovo.telco.dictionary.Functions.*;
6.9 +import java.io.BufferedWriter;
6.10 +import java.io.ByteArrayOutputStream;
6.11 +import java.io.DataOutputStream;
6.12 +import java.io.File;
6.13 +import java.io.FileOutputStream;
6.14 +import java.io.FileWriter;
6.15 +import java.io.IOException;
6.16 +import java.nio.ByteBuffer;
6.17 +import java.nio.charset.Charset;
6.18 +import java.util.ArrayList;
6.19 +import java.util.List;
6.20 +import java.util.logging.Level;
6.21 +import java.util.logging.Logger;
6.22 +import javax.xml.parsers.DocumentBuilder;
6.23 +import javax.xml.parsers.DocumentBuilderFactory;
6.24 +import javax.xml.parsers.ParserConfigurationException;
6.25 +import javax.xml.transform.Transformer;
6.26 +import javax.xml.transform.TransformerConfigurationException;
6.27 +import javax.xml.transform.TransformerException;
6.28 +import javax.xml.transform.TransformerFactory;
6.29 +import javax.xml.transform.dom.DOMSource;
6.30 +import javax.xml.transform.stream.StreamResult;
6.31 +import javax.xml.transform.stream.StreamSource;
6.32 +import javax.xml.xpath.XPath;
6.33 +import javax.xml.xpath.XPathConstants;
6.34 +import javax.xml.xpath.XPathExpression;
6.35 +import javax.xml.xpath.XPathExpressionException;
6.36 +import javax.xml.xpath.XPathFactory;
6.37 +import org.w3c.dom.Document;
6.38 +import org.w3c.dom.Node;
6.39 +import org.w3c.dom.NodeList;
6.40 +import org.xml.sax.SAXException;
6.41 +
6.42 /**
6.43 + * <p>
6.44 + * Generates dictionary files in StarDict format from source in our XML format.
6.45 + * </p>
6.46 + *
6.47 + * <p>
6.48 + * Number format should be: 32-bits unsigned number in network byte order
6.49 + * </p>
6.50 *
6.51 * @author Ing. František Kučera (frantovo.cz)
6.52 */
6.53 public class Generator {
6.54
6.55 + private static final Logger log = Logger.getLogger(Generator.class.getName());
6.56 + private static final String EMAIL_TOKEN = "ixumhht68";
6.57 + private final DocumentBuilderFactory documentBuilderFactory;
6.58 + private final DocumentBuilder documentBuilder;
6.59 + private final XPathFactory xpathFactory;
6.60 + private final XPath xpath;
6.61 + private final TransformerFactory xslFactory;
6.62 + private final Transformer xsl;
6.63 + private final Charset utf8;
6.64 +
6.65 + public Generator() throws ParserConfigurationException, TransformerConfigurationException {
6.66 + utf8 = Charset.forName("UTF-8");
6.67 +
6.68 + documentBuilderFactory = DocumentBuilderFactory.newInstance();
6.69 + documentBuilderFactory.setNamespaceAware(true);
6.70 + documentBuilder = documentBuilderFactory.newDocumentBuilder();
6.71 +
6.72 + xslFactory = TransformerFactory.newInstance();
6.73 + xsl = xslFactory.newTransformer(new StreamSource("concept.xsl"));
6.74 +
6.75 + xpathFactory = XPathFactory.newInstance();
6.76 + xpath = xpathFactory.newXPath();
6.77 + xpath.setNamespaceContext(getNamespaceContext());
6.78 + }
6.79 +
6.80 + private void generate(File folder, String filePrefix) {
6.81 + File infoFile = new File(folder, filePrefix + ".ifo");
6.82 + File dictFile = new File(folder, filePrefix + ".dict");
6.83 + File indexFile = new File(folder, filePrefix + ".idx");
6.84 + File synonymFile = new File(folder, filePrefix + ".syn");
6.85 +
6.86 + FileOutputStream dictOutputStream = null;
6.87 + DataOutputStream synonymOutputStream = null;
6.88 + DataOutputStream indexOutputStream = null;
6.89 + BufferedWriter infoWriter = null;
6.90 +
6.91 + try {
6.92 + dictOutputStream = new FileOutputStream(dictFile);
6.93 + synonymOutputStream = new DataOutputStream(new FileOutputStream(synonymFile));
6.94 + indexOutputStream = new DataOutputStream(new FileOutputStream(indexFile));
6.95 + infoWriter = new BufferedWriter(new FileWriter(infoFile));
6.96 +
6.97 + Document sourceDocument = documentBuilder.parse("../../data/dictionary.xml");
6.98 + XPathExpression termsXPath = xpath.compile("d:term/@completeForm|d:term/@abbreviation");
6.99 + // TODO: tags - labels/descriptions
6.100 + xsl.setParameter("tags", sourceDocument.getElementsByTagNameNS(DICTIONARY, "tags").item(0));
6.101 +
6.102 + /**
6.103 + * TODO: sorting
6.104 + */
6.105 + long offset = 0;
6.106 + long conceptIndex = 0;
6.107 + long synonymCount = 0;
6.108 + for (Node conceptNode : nodeIterable(sourceDocument.getElementsByTagNameNS(DICTIONARY, "concept"))) {
6.109 + ByteArrayOutputStream conceptXhtml = new ByteArrayOutputStream();
6.110 + xsl.transform(new DOMSource(conceptNode), new StreamResult(conceptXhtml));
6.111 + int length = conceptXhtml.size();
6.112 + dictOutputStream.write(conceptXhtml.toByteArray());
6.113 +
6.114 + NodeList nameNodes = (NodeList) termsXPath.evaluate(conceptNode, XPathConstants.NODESET);
6.115 + List<String> names = new ArrayList<>();
6.116 +
6.117 + for (Node nameNode : nodeIterable(nameNodes)) {
6.118 + String name = nameNode.getTextContent().trim();
6.119 + if (!name.isEmpty()) {
6.120 + names.add(name);
6.121 + }
6.122 + }
6.123 +
6.124 + synonymCount = +writeSynonyms(synonymOutputStream, names, conceptIndex);
6.125 + writeIndex(indexOutputStream, names.get(0), offset, length);
6.126 +
6.127 + offset = offset + length;
6.128 + conceptIndex++;
6.129 + }
6.130 +
6.131 + indexOutputStream.flush();
6.132 + writeInfo(infoWriter, sourceDocument, conceptIndex + 1, synonymCount, indexFile.length());
6.133 + } catch (SAXException | IOException | TransformerException | XPathExpressionException e) {
6.134 + log.log(Level.SEVERE, "unable to generate", e);
6.135 + } finally {
6.136 + close(dictOutputStream);
6.137 + close(synonymOutputStream);
6.138 + close(indexOutputStream);
6.139 + close(infoWriter);
6.140 + }
6.141 + }
6.142 +
6.143 + private void writeIndex(DataOutputStream indexOutputStream, String name, long offset, long length) throws IOException {
6.144 + indexOutputStream.write(name.getBytes(utf8));
6.145 + indexOutputStream.write(0);
6.146 + indexOutputStream.writeInt((int) offset); // unsigned int 32
6.147 + indexOutputStream.writeInt((int) length); // unsigned int 32
6.148 + }
6.149 +
6.150 + private int writeSynonyms(DataOutputStream synonymOutputStream, List<String> names, long baseIndex) throws IOException {
6.151 + if (names.size() > 1) {
6.152 + for (int i = 1; i < names.size(); i++) {
6.153 + String name = names.get(i);
6.154 + synonymOutputStream.write(name.getBytes(utf8));
6.155 + synonymOutputStream.write(0);
6.156 + synonymOutputStream.writeInt((int) baseIndex); // unsigned int 32
6.157 + }
6.158 + return names.size() - 1;
6.159 + } else {
6.160 + return 0;
6.161 + }
6.162 + }
6.163 +
6.164 + private void writeInfo(BufferedWriter infoWriter, Document sourceDocument, long wordcount, long synwourdcount, long idxfilesize) throws IOException {
6.165 + // TODO: values from document metadata
6.166 + infoWriter.write("StarDict's dict ifo file\n");
6.167 + infoWriter.write("version=2.4.2\n");
6.168 + infoWriter.write("bookname=Free Telco Dictionary\n");
6.169 + infoWriter.write("wordcount=" + wordcount + "\n");
6.170 + infoWriter.write("synwordcount=" + synwourdcount + "\n");
6.171 + infoWriter.write("idxfilesize=" + idxfilesize + "\n");
6.172 + infoWriter.write("idxoffsetbits=32\n");
6.173 + infoWriter.write("author=František Kučera\n");
6.174 + infoWriter.write("email=telco-dictionary." + EMAIL_TOKEN + "@" + "frantovo.cz\n");
6.175 + infoWriter.write("website=https://telco.frantovo.cz\n");
6.176 + infoWriter.write("description=A dictionary for telecommunications licensed under GNU FDL\n");
6.177 + infoWriter.write("date=2013.07.09\n");
6.178 + infoWriter.write("sametypesequence=h\n");
6.179 + }
6.180 +
6.181 public static void main(String[] args) {
6.182 -
6.183 + File outputFolder = new File("../../delivery/free-telco-dictionary");
6.184 + outputFolder.mkdir();
6.185 +
6.186 + try {
6.187 + Generator g = new Generator();
6.188 + g.generate(outputFolder, "telco");
6.189 + } catch (ParserConfigurationException | TransformerConfigurationException e) {
6.190 + log.log(Level.SEVERE, "error during initialization", e);
6.191 + }
6.192 }
6.193 }
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/IndexEntry.java Tue Jul 09 18:59:07 2013 +0200
7.3 @@ -0,0 +1,30 @@
7.4 +/**
7.5 + * Free Telco Dictionary
7.6 + * Copyright © 2013 František Kučera (frantovo.cz)
7.7 + *
7.8 + * This program is free software: you can redistribute it and/or modify
7.9 + * it under the terms of the GNU General Public License as published by
7.10 + * the Free Software Foundation, either version 3 of the License, or
7.11 + * (at your option) any later version.
7.12 + *
7.13 + * This program is distributed in the hope that it will be useful,
7.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.16 + * GNU General Public License for more details.
7.17 + *
7.18 + * You should have received a copy of the GNU General Public License
7.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
7.20 + */
7.21 +package cz.frantovo.telco.dictionary;
7.22 +
7.23 +/**
7.24 + *
7.25 + * @author Ing. František Kučera (frantovo.cz)
7.26 + */
7.27 +public class IndexEntry implements Comparable<IndexEntry> {
7.28 +
7.29 + @Override
7.30 + public int compareTo(IndexEntry o) {
7.31 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
7.32 + }
7.33 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/MappedNamespaceContext.java Tue Jul 09 18:59:07 2013 +0200
8.3 @@ -0,0 +1,63 @@
8.4 +/**
8.5 + * Free Telco Dictionary
8.6 + * Copyright © 2013 František Kučera (frantovo.cz)
8.7 + *
8.8 + * This program is free software: you can redistribute it and/or modify
8.9 + * it under the terms of the GNU General Public License as published by
8.10 + * the Free Software Foundation, either version 3 of the License, or
8.11 + * (at your option) any later version.
8.12 + *
8.13 + * This program is distributed in the hope that it will be useful,
8.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.16 + * GNU General Public License for more details.
8.17 + *
8.18 + * You should have received a copy of the GNU General Public License
8.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
8.20 + */
8.21 +package cz.frantovo.telco.dictionary;
8.22 +
8.23 +import static cz.frantovo.telco.dictionary.Functions.*;
8.24 +import java.util.Iterator;
8.25 +import java.util.Map;
8.26 +import java.util.Map.Entry;
8.27 +import javax.xml.namespace.NamespaceContext;
8.28 +
8.29 +/**
8.30 + *
8.31 + * @author Ing. František Kučera (frantovo.cz)
8.32 + */
8.33 +public class MappedNamespaceContext implements NamespaceContext {
8.34 +
8.35 + /**
8.36 + * maps prexix to namespace URI
8.37 + */
8.38 + private Map<String, String> prefixMap;
8.39 +
8.40 + public MappedNamespaceContext(Map<String, String> prefixMap) {
8.41 + this.prefixMap = prefixMap;
8.42 + }
8.43 +
8.44 + @Override
8.45 + public String getNamespaceURI(String prefix) {
8.46 + return prefixMap.get(prefix);
8.47 + }
8.48 +
8.49 + @Override
8.50 + public String getPrefix(String xmlns) {
8.51 + for (Entry<String, String> e : prefixMap.entrySet()) {
8.52 + if (equalz(xmlns, e.getValue())) {
8.53 + return e.getKey();
8.54 + }
8.55 + }
8.56 + return null;
8.57 + }
8.58 +
8.59 + /**
8.60 + * TODO: support multiple prefixes
8.61 + */
8.62 + @Override
8.63 + public Iterator getPrefixes(String xmlns) {
8.64 + return new OneItemIterator(getPrefix(xmlns));
8.65 + }
8.66 +}
8.67 \ No newline at end of file
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/OneItemIterator.java Tue Jul 09 18:59:07 2013 +0200
9.3 @@ -0,0 +1,49 @@
9.4 +/**
9.5 + * Free Telco Dictionary
9.6 + * Copyright © 2013 František Kučera (frantovo.cz)
9.7 + *
9.8 + * This program is free software: you can redistribute it and/or modify
9.9 + * it under the terms of the GNU General Public License as published by
9.10 + * the Free Software Foundation, either version 3 of the License, or
9.11 + * (at your option) any later version.
9.12 + *
9.13 + * This program is distributed in the hope that it will be useful,
9.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.16 + * GNU General Public License for more details.
9.17 + *
9.18 + * You should have received a copy of the GNU General Public License
9.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
9.20 + */
9.21 +package cz.frantovo.telco.dictionary;
9.22 +
9.23 +import java.util.Iterator;
9.24 +
9.25 +/**
9.26 + *
9.27 + * @author Ing. František Kučera (frantovo.cz)
9.28 + */
9.29 +public class OneItemIterator<T> implements Iterator<T> {
9.30 +
9.31 + private final T item;
9.32 + private boolean unused = true;
9.33 +
9.34 + public OneItemIterator(T item) {
9.35 + this.item = item;
9.36 + }
9.37 +
9.38 + @Override
9.39 + public boolean hasNext() {
9.40 + return unused;
9.41 + }
9.42 +
9.43 + @Override
9.44 + public T next() {
9.45 + return item;
9.46 + }
9.47 +
9.48 + @Override
9.49 + public void remove() {
9.50 + throw new UnsupportedOperationException("remove not supported");
9.51 + }
9.52 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/SynonymsEntry.java Tue Jul 09 18:59:07 2013 +0200
10.3 @@ -0,0 +1,30 @@
10.4 +/**
10.5 + * Free Telco Dictionary
10.6 + * Copyright © 2013 František Kučera (frantovo.cz)
10.7 + *
10.8 + * This program is free software: you can redistribute it and/or modify
10.9 + * it under the terms of the GNU General Public License as published by
10.10 + * the Free Software Foundation, either version 3 of the License, or
10.11 + * (at your option) any later version.
10.12 + *
10.13 + * This program is distributed in the hope that it will be useful,
10.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.16 + * GNU General Public License for more details.
10.17 + *
10.18 + * You should have received a copy of the GNU General Public License
10.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
10.20 + */
10.21 +package cz.frantovo.telco.dictionary;
10.22 +
10.23 +/**
10.24 + *
10.25 + * @author Ing. František Kučera (frantovo.cz)
10.26 + */
10.27 +public class SynonymsEntry implements Comparable<SynonymsEntry> {
10.28 +
10.29 + @Override
10.30 + public int compareTo(SynonymsEntry o) {
10.31 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
10.32 + }
10.33 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/java/dictionary-generator/src/cz/frantovo/telco/dictionary/Xmlns.java Tue Jul 09 18:59:07 2013 +0200
11.3 @@ -0,0 +1,41 @@
11.4 +/**
11.5 + * Free Telco Dictionary
11.6 + * Copyright © 2013 František Kučera (frantovo.cz)
11.7 + *
11.8 + * This program is free software: you can redistribute it and/or modify
11.9 + * it under the terms of the GNU General Public License as published by
11.10 + * the Free Software Foundation, either version 3 of the License, or
11.11 + * (at your option) any later version.
11.12 + *
11.13 + * This program is distributed in the hope that it will be useful,
11.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.16 + * GNU General Public License for more details.
11.17 + *
11.18 + * You should have received a copy of the GNU General Public License
11.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
11.20 + */
11.21 +package cz.frantovo.telco.dictionary;
11.22 +
11.23 +import java.util.HashMap;
11.24 +import java.util.Map;
11.25 +import javax.xml.namespace.NamespaceContext;
11.26 +
11.27 +/**
11.28 + * XML namespaces used in Telco dictionary
11.29 + *
11.30 + * @author Ing. František Kučera (frantovo.cz)
11.31 + */
11.32 +public class Xmlns {
11.33 +
11.34 + public static final String DICTIONARY = "https://telco.frantovo.cz/xmlns/dictionary";
11.35 +
11.36 + public static NamespaceContext getNamespaceContext() {
11.37 + Map<String, String> prefixMap = new HashMap<>();
11.38 + prefixMap.put("d", DICTIONARY);
11.39 + return new MappedNamespaceContext(prefixMap);
11.40 + }
11.41 +
11.42 + private Xmlns() {
11.43 + }
11.44 +}