Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 
 package org.gatein.mop.core.util;
 
 
 import java.util.Date;

Author(s):
Julien Viet
Version:
$Revision$
 
 public abstract class AbstractAttributes implements Attributes {
 
   protected abstract Object get(String name);
 
   protected abstract void set(String nameObject o);
 
   private <T> T getObject(String nameValueType<T> type, T defaultValue) {
     if (name == null) {
       throw new NullPointerException();
     }
     Object o = get(name);
     if (o == null) {
       return defaultValue;
     } else {
       return type.cast(o);
     }
   }
 
   public final Object getObject(String name) {
     if (name == null) {
       throw new NullPointerException();
     }
     Object o = get(name);
     if (o == null) {
       return null;
     } else {
       ValueType.get(o);
       return o;
     }
   }
 
   public final <T> void setObject(String name, T value) {
     if (name == null) {
       throw new NullPointerException();
     }
     if (value == null) {
       set(namenull);
     } else {
       ValueType.get(value);
       set(namevalue);
     }
   }
 
   public final ValueType<?> getType(String name) {
     if (name == null) {
       throw new NullPointerException();
     }
     Object o = get(name);
     if (o == null) {
       return null;
     } else {
       return ValueType.get(o);
     }
   }
 
   public final String getString(String name) {
     return getObject(name.null);
   }
 
   public final void setString(String nameString value) {
     setObject(namevalue);
   }
 
   public final Boolean getBoolean(String name) {
     return getObject(name.null);
   }
 
   public final void setBoolean(String nameBoolean value) {
     setObject(namevalue);
  }
  public final Integer getInteger(String name) {
    return getObject(name.null);
  }
  public final void setInteger(String nameInteger value) {
    setObject(namevalue);
  }
  public final Date getDate(String name) {
    return getObject(name.null);
  }
  public final void setDate(String nameDate value) {
    setObject(namevalue);
  }
  public final Double getDouble(String name) {
    return getObject(name.null);
  }
  public final void setDouble(String nameDouble value) {
    setObject(namevalue);
  }
  public final <T> T getValue(Key<T> key, T defaultValue) {
    return getObject(key.getName(), key.getType(), defaultValue);
  }
  public final <T> T getValue(Key<T> key) {
    return getObject(key.getName(), key.getType(), null);
  }
  public final <T> void setValue(Key<T> key, T value) {
    setObject(key.getName(), value);
  }
New to GrepCode? Check out our FAQ X