View Javadoc

1   /*
2    *  jDTAUS Core SPI
3    *  Copyright (C) 2005 Christian Schulte
4    *  <cs@schulte.it>
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19   *
20   */
21  package org.jdtaus.core.lang.spi;
22  
23  /**
24   * Manages memory allocations.
25   * <p>jDTAUS Core SPI {@code MemoryManager} specification to be used by
26   * implementations when allocating memory.</p>
27   *
28   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
29   * @version $JDTAUS: MemoryManager.java 8641 2012-09-27 06:45:17Z schulte $
30   * @see org.jdtaus.core.container.Container
31   */
32  public interface MemoryManager extends org.jdtaus.core.lang.Runtime
33  {
34      //--MemoryManager-----------------------------------------------------------
35  
36      /**
37       * Creates a new buffer of byte values.
38       *
39       * @param requested desired size of the buffer.
40       *
41       * @return a new buffer with length {@code requested}.
42       *
43       * @throws IllegalArgumentException if {@code requested} is negative.
44       * @throws OutOfMemoryError if there is not enough memory available.
45       */
46      byte[] allocateBytes( int requested );
47  
48      /**
49       * Creates a new buffer of short values.
50       *
51       * @param requested desired size of the buffer.
52       *
53       * @return a new buffer with length {@code requested}.
54       *
55       * @throws IllegalArgumentException if {@code requested} is negative.
56       * @throws OutOfMemoryError if there is not enough memory available.
57       */
58      short[] allocateShorts( int requested );
59  
60      /**
61       * Creates a new buffer of integer values.
62       *
63       * @param requested desired size of the buffer.
64       *
65       * @return a new buffer with length {@code requested}.
66       *
67       * @throws IllegalArgumentException if {@code requested} is negative.
68       * @throws OutOfMemoryError if there is not enough memory available.
69       */
70      int[] allocateIntegers( int requested );
71  
72      /**
73       * Creates a new buffer of long values.
74       *
75       * @param requested desired size of the buffer.
76       *
77       * @return a new buffer with length {@code requested}.
78       *
79       * @throws IllegalArgumentException if {@code requested} is negative.
80       * @throws OutOfMemoryError if there is not enough memory available.
81       */
82      long[] allocateLongs( int requested );
83  
84      /**
85       * Creates a new buffer of char values.
86       *
87       * @param requested desired size of the buffer.
88       *
89       * @return a new buffer with length {@code requested}.
90       *
91       * @throws IllegalArgumentException if {@code requested} is negative.
92       * @throws OutOfMemoryError if there is not enough memory available.
93       */
94      char[] allocateChars( int requested );
95  
96      /**
97       * Creates a new buffer of float values.
98       *
99       * @param requested desired size of the buffer.
100      *
101      * @return a new buffer with length {@code requested}.
102      *
103      * @throws IllegalArgumentException if {@code requested} is negative.
104      * @throws OutOfMemoryError if there is not enough memory available.
105      */
106     float[] allocateFloats( int requested );
107 
108     /**
109      * Creates a new buffer of double values.
110      *
111      * @param requested desired size of the buffer.
112      *
113      * @return a new buffer with length {@code requested}.
114      *
115      * @throws IllegalArgumentException if {@code requested} is negative.
116      * @throws OutOfMemoryError if there is not enough memory available.
117      */
118     double[] allocateDoubles( int requested );
119 
120     /**
121      * Creates a new buffer of boolean values.
122      *
123      * @param requested desired size of the buffer.
124      *
125      * @return a new buffer with length {@code requested}.
126      *
127      * @throws IllegalArgumentException if {@code requested} is negative.
128      * @throws OutOfMemoryError if there is not enough memory available.
129      */
130     boolean[] allocateBoolean( int requested );
131 
132     //-----------------------------------------------------------MemoryManager--
133 }