View Javadoc

1   /***
2    * ***************************************************************
3    * JADE - Java Agent DEvelopment Framework is a framework to develop
4    * multi-agent systems in compliance with the FIPA specifications.
5    * Copyright (C) 2000 CSELT S.p.A.
6    * 
7    * GNU Lesser General Public License
8    * 
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation,
12   * version 2.1 of the License.
13   * 
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the
21   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22   * Boston, MA  02111-1307, USA.
23   * **************************************************************
24   */
25  package JADE_SL.lang;
26  
27  import JADE_SL.onto.*;
28  import JADE_SL.abs.*;
29  
30  /***
31   * Base class for content language codecs that transform 
32   * AbsContentElements to/from sequences of bytes
33   * @author Giovanni Caire - TILAB
34   */
35  public abstract class ByteArrayCodec extends Codec{
36  
37      /***
38       * Construct a ByteArrayCodec object with the given name
39       */
40      public ByteArrayCodec(String name) {
41      	super(name);
42      }
43  
44      /***
45       * Encodes a content into a byte array.
46       * @param content the content as an abstract descriptor.
47       * @return the content as a byte array.
48       * @throws CodecException
49       */
50      public abstract byte[] encode(AbsContentElement content) 
51              throws CodecException;
52  
53      /***
54       * Encodes a content into a byte array.
55       * @param ontology the ontology 
56       * @param content the content as an abstract descriptor.
57       * @return the content as a byte array.
58       * @throws CodecException
59       */
60      public abstract byte[] encode(Ontology ontology, AbsContentElement content) 
61              throws CodecException;
62  
63      /***
64       * Decodes the content to an abstract description.
65       * @param content the content as a byte array.
66       * @return the content as an abstract description.
67       * @throws CodecException
68       */
69      public abstract AbsContentElement decode(byte[] content) 
70              throws CodecException;
71  
72      /***
73       * Decodes the content to an abstract description.
74       * @param ontology the ontology.
75       * @param content the content as a byte array.
76       * @return the content as an abstract description.
77       * @throws CodecException
78       */
79      public abstract AbsContentElement decode(Ontology ontology, byte[] content) 
80              throws CodecException;
81  
82  }
83