1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.ws.processor.model;
  27 
  28 import com.sun.tools.internal.ws.wsdl.framework.Entity;
  29 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
  30 
  31 import java.util.Collections;
  32 import java.util.HashMap;
  33 import java.util.Iterator;
  34 import java.util.Map;
  35 
  36 import org.xml.sax.Locator;
  37 
  38 /**
  39  *
  40  * @author WS Development Team
  41  */
  42 public abstract class ModelObject {
  43     public abstract void accept(ModelVisitor visitor) throws Exception;
  44 
  45     private final Entity entity;
  46     protected ErrorReceiver errorReceiver;
  47 
  48     protected ModelObject(Entity entity) {
  49         this.entity = entity;
  50     }
  51 
  52     public void setErrorReceiver(ErrorReceiver errorReceiver) {
  53         this.errorReceiver = errorReceiver;
  54     }
  55 
  56     public Entity getEntity() {
  57         return entity;
  58     }
  59 
  60     public Object getProperty(String key) {
  61         if (_properties == null) {
  62             return null;
  63         }
  64         return _properties.get(key);
  65     }
  66 
  67     public void setProperty(String key, Object value) {
  68         if (value == null) {
  69             removeProperty(key);
  70             return;
  71         }
  72 
  73         if (_properties == null) {
  74             _properties = new HashMap();
  75         }
  76         _properties.put(key, value);
  77     }
  78 
  79     public void removeProperty(String key) {
  80         if (_properties != null) {
  81             _properties.remove(key);
  82         }
  83     }
  84 
  85     public Iterator getProperties() {
  86         if (_properties == null) {
  87             return Collections.emptyList().iterator();
  88         } else {
  89             return _properties.keySet().iterator();
  90         }
  91     }
  92 
  93     public Locator getLocator(){
  94         return entity.getLocator();
  95     }
  96 
  97     public Map getPropertiesMap() {
  98         return _properties;
  99     }
 100 
 101     public void setPropertiesMap(Map m) {
 102         _properties = m;
 103     }
 104 
 105     public String getJavaDoc() {
 106         return javaDoc;
 107     }
 108 
 109     public void setJavaDoc(String javaDoc) {
 110         this.javaDoc = javaDoc;
 111     }
 112 
 113     private String javaDoc;
 114     private Map _properties;
 115 }