Statistics
| Revision:

gvsig-sldtools / org.gvsig.sld / org.gvsig.sldsupport / org.gvsig.sldsupport.lib / org.gvsig.sldsupport.lib.impl / src / main / java / org / gvsig / sldsupport / impl / sld / parsing / expression / ArithmeticElement.java @ 46

History | View | Annotate | Download (2.84 KB)

1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldsupport.impl.sld.parsing.expression;
27

    
28
import java.io.IOException;
29

    
30
import org.xmlpull.v1.XmlPullParser;
31
import org.xmlpull.v1.XmlPullParserException;
32

    
33
import org.gvsig.sldsupport.exception.InvalidSLDObjectException;
34
import org.gvsig.sldsupport.exception.SLDReadException;
35
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
36
import org.gvsig.sldsupport.impl.util.XmlBuilder;
37
import org.gvsig.sldsupport.sld.filter.expression.SLDExpression;
38
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDArithmeticOperator;
39

    
40
public class ArithmeticElement {
41

    
42
    public static void append(SLDArithmeticOperator obj, XmlBuilder xb,
43
        String version) throws InvalidSLDObjectException,
44
        UnsupportedSLDObjectException {
45

    
46
        xb.openTag(obj.getOperatorName());
47
        ExpressionElement.append(obj.getFirstExpression(), xb, version);
48
        ExpressionElement.append(obj.getSecondExpression(), xb, version);
49
        xb.closeTag();
50
    }
51

    
52
    public static SLDArithmeticOperator parse(XmlPullParser parser,
53
        String version) throws XmlPullParserException, IOException,
54
        SLDReadException {
55

    
56
        SLDArithmeticOperator resp = new SLDArithmeticOperator();
57
        String op_name = parser.getName();
58
        resp.setOperatorName(op_name);
59
        parser.nextTag();
60

    
61
        SLDExpression expre = null;
62
        expre = ExpressionElement.parse(parser, version);
63
        resp.setFirstExpression(expre);
64
        expre = ExpressionElement.parse(parser, version);
65
        resp.setSecondExpression(expre);
66

    
67
        parser.require(XmlPullParser.END_TAG, null, op_name);
68
        parser.nextTag();
69
        return resp;
70
    }
71
}