Fixed json api to handle words not found.
This commit is contained in:
parent
ea46ddebb0
commit
aed2e307ba
1 changed files with 29 additions and 17 deletions
|
@ -73,7 +73,7 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
String linea, dicts = req.getParameter("dicts"), dicDescrip[], jwf = req.getParameter("jwf"), tag;
|
String linea = null, dicts = req.getParameter("dicts"), dicDescrip[], jwf = req.getParameter("jwf"), tag;
|
||||||
Definitions defs;
|
Definitions defs;
|
||||||
ByteDictionarySource dict_source;
|
ByteDictionarySource dict_source;
|
||||||
if (jwf!=null) format = JSON;
|
if (jwf!=null) format = JSON;
|
||||||
|
@ -132,9 +132,9 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
{
|
{
|
||||||
out.println(jwf + "({\"words\":{");
|
out.println(jwf + "({\"words\":{");
|
||||||
}
|
}
|
||||||
|
scanner.clearTokens();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
scanner.clearTokens();
|
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case INTERNAL:
|
case INTERNAL:
|
||||||
|
@ -154,25 +154,37 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
scanner.scanLine(linea);
|
scanner.scanLine(linea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (linea!=null) sl.writeLog("1\t2\t" + linea);
|
||||||
|
sl.writeException(e);
|
||||||
|
}
|
||||||
scanner.finishUp();
|
scanner.finishUp();
|
||||||
|
try
|
||||||
|
{
|
||||||
words = scanner.getWordArray();
|
words = scanner.getWordArray();
|
||||||
if (words!=null)
|
if (words!=null)
|
||||||
{
|
{
|
||||||
for (i=0; i<words.length; i++)
|
for (i=0; i<words.length; i++)
|
||||||
{
|
{
|
||||||
linea = words[i].getDef();
|
word = words[i];
|
||||||
|
linea = word.getDef();
|
||||||
if (linea == null) continue;
|
if (linea == null) continue;
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case INTERNAL:
|
case INTERNAL:
|
||||||
out.println(words[i].getWylie());
|
out.println(word.getWylie());
|
||||||
out.println(linea);
|
out.println(linea);
|
||||||
out.println();
|
out.println();
|
||||||
break;
|
break;
|
||||||
case JSON:
|
case JSON:
|
||||||
out.println("\"" + BasicTibetanTranscriptionConverter.wylieToHTMLUnicode(words[i].token) + "\": [");
|
defs = word.getDefs();
|
||||||
defs = words[i].getDefs();
|
|
||||||
dict_source = (ByteDictionarySource)defs.getDictionarySource();
|
dict_source = (ByteDictionarySource)defs.getDictionarySource();
|
||||||
|
if(dict_source==null) out.println("\"" + word.token + "\": [");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out.println("\"" + BasicTibetanTranscriptionConverter.wylieToHTMLUnicode(word.token) + "\": [");
|
||||||
k=0;
|
k=0;
|
||||||
for (j=0; j<defs.def.length; j++)
|
for (j=0; j<defs.def.length; j++)
|
||||||
{
|
{
|
||||||
|
@ -184,6 +196,7 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
if (j==defs.def.length-1) out.println();
|
if (j==defs.def.length-1) out.println();
|
||||||
else out.println(",");
|
else out.println(",");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
out.print("]");
|
out.print("]");
|
||||||
if (i<words.length-1) out.println(",");
|
if (i<words.length-1) out.println(",");
|
||||||
}
|
}
|
||||||
|
@ -196,7 +209,6 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
if (word!=null) sl.writeLog("1\t2\t" + word.getWylie());
|
if (word!=null) sl.writeLog("1\t2\t" + word.getWylie());
|
||||||
sl.writeException(e);
|
sl.writeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.clearTokens();
|
scanner.clearTokens();
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue