001    package org.mesopotamia.lang.java;
002    
003    import org.mesopotamia.MesopotamiaException;
004    import org.mesopotamia.NodeData;
005    import org.mesopotamia.RepositoryLanguage;
006    import org.mesopotamia.Scan;
007    import org.mesopotamia.lang.java.ref.TypeSpecInfo;
008    import org.w3c.dom.Element;
009    
010    import biz.hammurapi.util.Visitable;
011    import biz.hammurapi.util.Visitor;
012    
013    public class Typecast extends UnaryExpressionNotPlusMinus {
014    
015            public Typecast(NodeData xData, Class<?> context, Scan scan,
016                            RepositoryLanguage language, Object environment) throws MesopotamiaException {
017                    super(xData, context, scan, language, environment);
018    
019                    // Select attributes
020                    Expression = selectSingleElement(UnaryExpression.class,
021                                    "#org.mesopotamia.lang.java.UnaryExpression");
022                    TypeSpecification = selectSingleElement(TypeSpecification.class, "TYPE");
023    
024            }
025    
026            public void toDom(Element holder) {
027                    super.toDom(holder);
028    
029                    // Serialize attributes
030                    setElement(holder, "Expression", Expression);
031                    setElement(holder, "TypeSpecification", TypeSpecification);
032            }
033    
034            // Attributes
035            private UnaryExpression Expression;
036    
037            private TypeSpecification TypeSpecification;
038    
039            // Accessors
040            public UnaryExpression getExpression() {
041                    return Expression;
042            }
043    
044            public TypeSpecification getTypeSpecification() {
045                    return TypeSpecification;
046            }
047    
048            protected void acceptChildren(Visitor visitor) {
049                    super.acceptChildren(visitor);
050                    // Visiting non-text attributes
051                    if (Expression instanceof Visitable) {
052                            ((Visitable) Expression).accept(visitor);
053                    }
054                    if (TypeSpecification instanceof Visitable) {
055                            ((Visitable) TypeSpecification).accept(visitor);
056                    }
057            }
058            
059            @Override
060            public TypeSpecInfo getTypeSpecInfo() {
061                    return getTypeSpecification();
062            }
063    
064    }