Revision: 15281
http://gate.svn.sourceforge.net/gate/?rev=15281&view=rev
Author: ian_roberts
Date: 2012-01-31 17:45:17 +0000 (Tue, 31 Jan 2012)
Log Message:
-----------
Relaxed the sanity checks in setTarget a bit - we don't really care what
concrete class the target object has, only that it is a LanguageAnalyser and
that it provides grammarURL and encoding parameters.
Modified Paths:
--------------
gate/trunk/src/gate/gui/jape/JapeViewer.java
Modified: gate/trunk/src/gate/gui/jape/JapeViewer.java
===================================================================
--- gate/trunk/src/gate/gui/jape/JapeViewer.java 2012-01-31 15:09:11 UTC
(rev 15280)
+++ gate/trunk/src/gate/gui/jape/JapeViewer.java 2012-01-31 17:45:17 UTC
(rev 15281)
@@ -179,7 +179,24 @@
@Override
public void setTarget(Object target) {
- if(target == null || !(target instanceof gate.creole.Transducer ||
target.getClass().getName().equals("gate.jape.plus.Transducer"))) {
+ if(target == null) {
+ throw new NullPointerException("JAPE viewer received a null target");
+ }
+ // check that the target is one we can work with - it needs to be a
+ // LanguageAnalyser that has grammarURL and encoding parameters.
+ boolean targetOK = true;
+ if(target instanceof LanguageAnalyser) {
+ try {
+ ((LanguageAnalyser)target).getParameterValue("grammarURL");
+ ((LanguageAnalyser)target).getParameterValue("encoding");
+ } catch(ResourceInstantiationException rie) {
+ targetOK = false;
+ }
+ } else {
+ targetOK = false;
+ }
+
+ if(!targetOK) {
throw new IllegalArgumentException(
"The GATE jape viewer can only be used with a GATE jape
transducer!\n"
+ target.getClass().toString()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs