|
CLDC的类库API
如果不严格的说,CLDC的类库是J2SE的一个小的子集,有以下这种近似关系成立,即J2SE包含CDC包含CLDC。但要注意CLDC并未完全包含于J2SE,它还包括一些专门针对无线设施的类。所以可以把CLDC的类库简要划分为两部分:从J2SE继承的类和CLDC专有的类。
1. 从J2SE继承的类
|
|
这部分包括三个package,即java.lang,java.util和java.io。注意即使这些从J2SE继承的的类,也是大大“缩了水”的。例如java.util的类与接口由J2SE的47个缩减到10个。另外两个也有相应缩减。
系统类
From java.lang: Object, Class, Runtime, System, Thread, Runnable, String, StringBuffer, Throwable
数据类型类
From java.lang: Boolean, Byte, Short, Integer, Long, Character
容器类(container class)
From java.util: Vector, Stack, Hashtable, Enumeration
I/O 类
From java.i InputStream, OutputStream, ByteArrayInputStream, ByteArrayOutputStream, DataInput, DataOutput, DataInputStream, DataOutputStream, Reader, Writer, InputStreamReader, OutputStreamWriter, PrintStream
日期与时间类
From java.util: Calendar, Date, TimeZone
附加的实用类
java.util.Random, java.lang.Math
异常类(Exception Classes)
From java.lang: Exception, ClassNotFoundException, IllegalAccessException, InstantiationException, InterruptedException, RuntimeException, ArithmeticException, ArrayStoreException, ClassCastException, IllegalArgumentException, IllegalThreadStateException, NumberFormatException, IllegalMonitorStateException, IndexOutOfBoundsException, ArrayIndexOutOfBoundsException, StringIndexOutOfBoundsException, NegativeArraySizeException, NullPointerException, SecurityException
From java.util: EmptyStackException, NoSuchElementException
From java.i EOFException, IOException, InterruptedException, UnsupportedEncodingException, UTFDataFormatException
错误类
From java.lang: Error, VirtualMachineError, OutOfMemoryError
2. CLDC专有的类
这里sun提供了javax.microedition.io包。用它来提供与外界沟通的桥梁。(注:就像在J2SE中我们利用java.net.*)注意,所有的连接都由javax.microedition.Connector创建。例如: 你可以打开一个http连接通过Connector.open("http://www.chinajavaworld.com")
javax.microedition.io的接口包括: Connection, InputConnection, OutputConnection, StreamConnection, ContentConnection, DatagramConnection, StreamConnectionNotifier
这里再说明一点,实际上你也可以看出,CLDC所包括的类库,并不足以开发应用程序。例如,没有UI界面的支持等。这也正是CLDC的设计理念。CLDC本身就从未想过要解决所有的问题。这些问题要靠其上层的Profile-MIDP来解决。例如javax.microedition.lcdui就是定义在MIDP中的UI包。 |