| 1 | /** |
| 2 | * Copyright (C) 2006 NetMind Consulting Bt. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 3 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | package hu.netmind.beankeeper.model.impl; |
| 20 | |
| 21 | import org.apache.log4j.Logger; |
| 22 | import java.util.List; |
| 23 | import java.util.ArrayList; |
| 24 | import java.util.Map; |
| 25 | import java.util.HashMap; |
| 26 | import hu.netmind.beankeeper.common.StoreException; |
| 27 | import hu.netmind.beankeeper.model.*; |
| 28 | |
| 29 | /** |
| 30 | * Null handler is a class handler for interfaces and reserved classes. |
| 31 | * It contains no attributes, so all methods return default values |
| 32 | * statically. |
| 33 | * @author Brautigam Robert |
| 34 | * @version Revision: $Revision$ |
| 35 | */ |
| 36 | public class StrictNullHandler implements StrictClassHandler |
| 37 | { |
| 38 | private static Logger logger = Logger.getLogger(StrictNullHandler.class); |
| 39 | |
| 40 | private ClassEntry sourceEntry; |
| 41 | |
| 42 | StrictNullHandler(ClassEntry sourceEntry) |
| 43 | { |
| 44 | // Init |
| 45 | this.sourceEntry=sourceEntry; |
| 46 | } |
| 47 | |
| 48 | public ClassEntry getSourceEntry() |
| 49 | { |
| 50 | return sourceEntry; |
| 51 | } |
| 52 | |
| 53 | public boolean hasChanged() |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | public void update() |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | public Map getAttributeTypes() |
| 63 | { |
| 64 | return new HashMap(); |
| 65 | } |
| 66 | |
| 67 | public List getAttributeNames() |
| 68 | { |
| 69 | return new ArrayList(); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Always throws exception. |
| 74 | */ |
| 75 | public Object getAttributeValue(Object obj, String attributeName) |
| 76 | { |
| 77 | throw new StoreException("object value cannot be get, name: "+attributeName+" in nullhandler for: "+sourceEntry); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Always returns exception. |
| 82 | */ |
| 83 | public void setAttributeValue(Object obj, String attributeName, Object value) |
| 84 | { |
| 85 | throw new StoreException("object value cannot be set, objectclass: "+obj.getClass()+" name: "+attributeName+" on nullhandler for type: "+sourceEntry); |
| 86 | } |
| 87 | |
| 88 | } |
| 89 | |
| 90 | |