01: /*
02: * File: InfoMessage.java
03: * Project: jMOS, com.aranova.java.jmos.messages
04: * Revision: 0.9 - Inicial
05: * Date: 27-oct-2005 17:09:16
06: *
07: * Copyright (C) Aragón Innovación Tecnológica S.L.L.
08: * All rights reserved.
09: *
10: * This software is distributed under the terms of the Aranova License version 1.0.
11: * See the terms of the Aranova License in the documentation provided with this software.
12: */
13:
14: package com.aranova.java.jmos.messages;
15:
16: import java.lang.reflect.Field;
17: import java.util.LinkedHashMap;
18: import java.util.Map;
19:
20: import com.aranova.java.jmos.annotations.MOSAttribute;
21: import com.aranova.java.jmos.annotations.MOSMessage;
22:
23: /**
24: * Clase para guardar la información de un mensaje MOS.
25: *
26: * @author <a href="http://www.aranova.net/contactar/">Daniel Sánchez</a>
27: * @version 0.9.1
28: * @since 0.9
29: */
30: public class InfoMessage {
31: private final MOSMessage _message;
32: private final Map<String, InfoAttribute> _fields;
33:
34: /**
35: * Constructor de la calse.
36: * @param message
37: */
38: public InfoMessage(final MOSMessage message) {
39: _message = message;
40: _fields = new LinkedHashMap<String, InfoAttribute>();
41: }
42:
43: /**
44: * @return Returns the message.
45: */
46: public MOSMessage getMessage() {
47: return _message;
48: }
49:
50: /**
51: * @return Returns the fields.
52: */
53: public Map<String, InfoAttribute> getFields() {
54: return _fields;
55: }
56:
57: /**
58: * @param mosName
59: * @return Retorna un campo.
60: */
61: public Field getField(final String mosName) {
62: if (_fields.containsKey(mosName)) {
63: return _fields.get(mosName).getField();
64: }
65: return null;
66: }
67:
68: /**
69: * Añade un campo a la colección.
70: * @param attribute
71: * @param field
72: */
73: public void addField(final MOSAttribute attribute, final Field field) {
74: _fields.put(attribute.name(), new InfoAttribute(attribute,
75: field));
76: }
77:
78: /**
79: * @param name
80: * @return True if field is contains XML.
81: */
82: public boolean isXMLField(final String name) {
83: if (_fields.containsKey(name)) {
84: return _fields.get(name).getAttribute().isXML();
85: }
86: return false;
87: }
88:
89: /**
90: * @param fields
91: */
92: public void addFields(final Map<String, InfoAttribute> fields) {
93: _fields.putAll(fields);
94: }
95: }
|