001 package org.mesopotamia.lang.java; 002 003 import java.util.List; 004 005 import org.mesopotamia.MesopotamiaException; 006 import org.mesopotamia.NodeData; 007 import org.mesopotamia.RepositoryLanguage; 008 import org.mesopotamia.Scan; 009 import org.w3c.dom.Element; 010 011 import biz.hammurapi.util.CollectionVisitable; 012 import biz.hammurapi.util.Visitor; 013 014 @SuppressWarnings("unchecked") 015 public class Field extends JavaLanguageElement { 016 017 public Field( 018 NodeData xData, 019 Class<?> context, 020 Scan scan, 021 RepositoryLanguage language, 022 Object environment) throws MesopotamiaException { 023 024 super(xData, context, scan, language, environment); 025 026 // Select attributes 027 if (language.supportsTokenName("ANNOTATION")) { 028 Modifiers = selectText(Modifier.class, "MODIFIERS/!ANNOTATION"); 029 Annotations = select(Annotation.class, "MODIFIERS/ANNOTATION"); 030 } else { 031 Modifiers = selectText(Modifier.class, "MODIFIERS/*"); 032 } 033 } 034 035 public void toDom(Element holder) { 036 super.toDom(holder); 037 038 // Serialize attributes 039 setElement(holder, "Modifiers", Modifiers); 040 setElement(holder, "Annotations", Annotations); 041 } 042 043 // Attributes 044 private List<String> Modifiers; 045 046 private List<Annotation> Annotations = emptyList; 047 048 // Accessors 049 public List<String> getModifiers() { 050 return Modifiers; 051 } 052 053 public List<Annotation> getAnnotations() { 054 return Annotations; 055 } 056 057 protected void acceptChildren(Visitor visitor) { 058 super.acceptChildren(visitor); 059 // Visiting non-text attributes 060 new CollectionVisitable(Annotations, false).accept(visitor); 061 } 062 063 }