Revision 45011 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractFunction.java
AbstractFunction.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.InputStream; |
5 |
import java.net.MalformedURLException; |
|
5 | 6 |
import java.net.URI; |
6 | 7 |
import java.net.URISyntaxException; |
7 | 8 |
import java.net.URL; |
... | ... | |
20 | 21 |
import org.apache.commons.math.util.MathUtils; |
21 | 22 |
import org.gvsig.expressionevaluator.Code; |
22 | 23 |
import org.gvsig.expressionevaluator.Codes; |
24 |
import org.gvsig.expressionevaluator.ExpressionRuntimeException; |
|
25 |
import org.gvsig.expressionevaluator.Formatter; |
|
23 | 26 |
import org.gvsig.expressionevaluator.Function; |
24 | 27 |
import org.gvsig.expressionevaluator.I18N; |
25 | 28 |
import org.gvsig.expressionevaluator.Interpreter; |
... | ... | |
416 | 419 |
I18N.Expected_XexpectedX_and_found_XfoundX("Temporal/Date",type) |
417 | 420 |
); |
418 | 421 |
} |
422 |
|
|
423 |
public URL getURL(Object[] args, int index) throws MalformedURLException { |
|
424 |
Object obj = getObject(args, index); |
|
425 |
if( obj == null ) { |
|
426 |
return null; |
|
427 |
} |
|
428 |
URL url; |
|
429 |
if( obj instanceof URL ) { |
|
430 |
url = (URL) obj; } else if( obj instanceof CharSequence ) { |
|
431 |
url = new URL(((CharSequence)obj).toString()); |
|
432 |
} else if( obj instanceof File ) { |
|
433 |
url = ((File)obj).toURI().toURL(); |
|
434 |
} else if( obj instanceof URI ) { |
|
435 |
url = ((URI)obj).toURL(); |
|
436 |
} else { |
|
437 |
throw new ExpressionRuntimeException("The "+this.name()+" function require a File, URI or a String and a received a '"+obj.getClass().getSimpleName()+"'."); |
|
438 |
} |
|
439 |
return url; |
|
440 |
} |
|
419 | 441 |
|
420 | 442 |
protected boolean getBoolean(Object args[], int n, Double accuracy) { |
421 | 443 |
if( args.length < n ) { |
... | ... | |
566 | 588 |
} |
567 | 589 |
return r; |
568 | 590 |
} |
569 |
|
|
591 |
|
|
592 |
@Override |
|
593 |
public String toString(Codes args, Formatter<Code> formatter) { |
|
594 |
return null; |
|
595 |
} |
|
596 |
|
|
570 | 597 |
} |
Also available in: Unified diff