Java Doc for Protocol.java in  » 6.0-JDK-Modules » j2me » com » sun » midp » io » j2me » file » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » com.sun.midp.io.j2me.file 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.sun.midp.io.j2me.file.Protocol

Protocol
public class Protocol extends ConnectionBaseAdapter implements FileConnection(Code)
This class implements the necessary functionality for a File connection.


Field Summary
 InputStreamfis
    
 OutputStreamfos
    

Constructor Summary
public  Protocol()
     Constructor for file connection implementation.

Method Summary
public  longavailableSize()
    
public  booleancanRead()
    
public  booleancanWrite()
    
final protected  voidcheckReadPermission()
     Checks that the application has permission to read.
final protected  voidcheckRootReadPermission()
     Checks that the application has permission to read the root path.
final protected  voidcheckWritePermission()
     Checks that the application has permission to write.
protected  voidcloseInputStream()
     Called once by each child input stream.
protected  voidcloseOutputStream()
     Called once by each child output stream.
protected  voidconnect(String name, int mode, boolean timeouts)
     Establishes the connection.
public  voidcreate()
    
public  voiddelete()
    
public  longdirectorySize(boolean includeSubDirs)
    
protected  voiddisconnect()
     Free up the connection resources.
protected  voidensureConnected()
     Checks that the connection is already open.
protected  voidensureOpenAndConnected()
     Checks that the connection is already open and connected.
public  booleanexists()
    
public  longfileSize()
    
protected  voidflush()
     Forces any buffered output bytes to be written out.
public  StringgetName()
    
public  StringgetPath()
    
public  StringgetURL()
    
public  booleanisDirectory()
    
public  booleanisHidden()
    
public  booleanisOpen()
    
public  longlastModified()
    
public  Enumerationlist()
    
public  Enumerationlist(String filter, boolean includeHidden)
    
public static  VectorlistRoots()
     Gets an array of file system roots.
public  voidmkdir()
    
public  InputStreamopenInputStream()
     Open and return an input stream for a connection.
public  OutputStreamopenOutputStream()
     Open and return an output stream for a connection.
public  OutputStreamopenOutputStream(long byteOffset)
    
public  ConnectionopenPrim(String name, int mode, boolean timeouts)
     Opens the file connection.
public  ConnectionopenPrim(SecurityToken token, String name)
     Opens the file connection and receive security token.
public  ConnectionopenPrim(SecurityToken token, String name, int mode)
     Opens the file connection and receive security token.
protected  intreadBytes(byte b, int off, int len)
     Reads up to len bytes of data from the input stream into an array of bytes, blocks until at least one byte is available.
Parameters:
  b - the buffer into which the data is read.
Parameters:
  off - the start offset in array bat which the data is written.
Parameters:
  len - the maximum number of bytes to read.
public  voidrename(String newName)
    
public  voidsetFileConnection(String fileName)
    
public  voidsetHidden(boolean hidden)
    
public  voidsetReadable(boolean readable)
    
public  voidsetWritable(boolean writable)
    
public  longtotalSize()
    
public  voidtruncate(long byteOffset)
    
public  longusedSize()
    
protected  intwriteBytes(byte b, int off, int len)
     Writes len bytes from the specified byte array starting at offset off to this output stream.

Polling the native code is done here to allow for simple asynchronous native code to be written.


Field Detail
fis
InputStream fis(Code)
Input stream associated with this connection



fos
OutputStream fos(Code)
Output stream associated with this connection




Constructor Detail
Protocol
public Protocol()(Code)
Constructor for file connection implementation.




Method Detail
availableSize
public long availableSize()(Code)



canRead
public boolean canRead()(Code)



canWrite
public boolean canWrite()(Code)



checkReadPermission
final protected void checkReadPermission() throws InterruptedIOException(Code)
Checks that the application has permission to read.
throws:
  InterruptedIOException - if the permission dialog isterminated before completed
throws:
  SecurityException - if read is not allowed
throws:
  IllegalModeException - if connection is write only



checkRootReadPermission
final protected void checkRootReadPermission() throws InterruptedIOException(Code)
Checks that the application has permission to read the root path.
throws:
  InterruptedIOException - if the permission dialog isterminated before completed
throws:
  SecurityException - if read is not allowed
throws:
  IllegalModeException - if connection is write only



checkWritePermission
final protected void checkWritePermission() throws InterruptedIOException(Code)
Checks that the application has permission to write.
throws:
  InterruptedIOException - if the permission dialog isterminated before completed
throws:
  SecurityException - if write is not allowed
throws:
  IllegalModeException - if connection is read only



closeInputStream
protected void closeInputStream() throws IOException(Code)
Called once by each child input stream. If the input stream is marked open, it will be marked closed and the if the connection and output stream are closed the disconnect method will be called.
exception:
  IOException - if the subclass throws one



closeOutputStream
protected void closeOutputStream() throws IOException(Code)
Called once by each child output stream. If the output stream is marked open, it will be marked closed and the if the connection and input stream are closed the disconnect method will be called.
exception:
  IOException - if the subclass throws one



connect
protected void connect(String name, int mode, boolean timeouts) throws IOException(Code)
Establishes the connection.
Parameters:
  name - URL path fragment
Parameters:
  mode - access mode
Parameters:
  timeouts - flag to indicate that timeouts allowed
throws:
  IOException - if an error occurs



create
public void create() throws IOException(Code)



delete
public void delete() throws java.io.IOException(Code)



directorySize
public long directorySize(boolean includeSubDirs) throws IOException(Code)



disconnect
protected void disconnect() throws IOException(Code)
Free up the connection resources.
exception:
  IOException - if an I/O error occurs.



ensureConnected
protected void ensureConnected() throws IOException(Code)
Checks that the connection is already open.
throws:
  IOException - if the connection is closed



ensureOpenAndConnected
protected void ensureOpenAndConnected() throws IOException(Code)
Checks that the connection is already open and connected.
throws:
  ConnectionClosedException - if the connection is closed
throws:
  IOException - if any error occurs while connecting



exists
public boolean exists()(Code)



fileSize
public long fileSize() throws IOException(Code)



flush
protected void flush() throws IOException(Code)
Forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written that have been buffered by the connection, should immediately be written to their intended destination.

The flush method of ConnectionBaseAdapter does nothing.
exception:
  IOException - if an I/O error occurs.




getName
public String getName()(Code)



getPath
public String getPath()(Code)



getURL
public String getURL()(Code)



isDirectory
public boolean isDirectory()(Code)



isHidden
public boolean isHidden()(Code)



isOpen
public boolean isOpen()(Code)



lastModified
public long lastModified()(Code)



list
public Enumeration list() throws IOException(Code)



list
public Enumeration list(String filter, boolean includeHidden) throws IOException(Code)



listRoots
public static Vector listRoots()(Code)
Gets an array of file system roots. up-to-date array of file system roots;empty array is returned if there are no roots available.



mkdir
public void mkdir() throws IOException(Code)



openInputStream
public InputStream openInputStream() throws IOException(Code)
Open and return an input stream for a connection. The connection's target must already exist and be accessible for the input stream to be created. An open input stream
exception:
  IOException - if an I/O error occurs, if the method is invokedon a directory, if the connection's target does notyet exist, or the connection's target is not accessible.
exception:
  IllegalModeException - if the application does have readaccessto the connection's target but has opened the connection inConnector.WRITE mode.
exception:
  SecurityException - If the application is not granted readaccess to the connection's target.



openOutputStream
public OutputStream openOutputStream() throws IOException(Code)
Open and return an output stream for a connection. The output stream is positioned at the start of the file. Writing data to the output stream overwrites the contents of the files (i.e. does not insert data). Writing data to output streams beyond the current end of file automatically extends the file size. The connection's target must already exist and be accessible for the output stream to be created. Protocol.openOutputStream(long) should be used to position an output stream to a different position in the file.

Changes made to a file through an output stream may not be immediately made to the actual file residing on the file system because platform and implementation specific use of caching and buffering of the data. Stream contents and file length extensions are not necessarily visible outside of the application immediately unless flush() is called on the stream.? The returned output stream is automatically and synchronously flushed when it is closed.

An open output stream
exception:
  IOException - If an I/O error occurs, if the method isinvoked ona directory, the file does not yet exist, or the connection'starget is not accessible.
exception:
  IllegalModeException - if the application does have writeaccessto the connection's target but has opened the connection inConnector.READ mode.
exception:
  SecurityException - If the application is not granted writeaccess to the connection's target.
See Also:   Protocol.openOutputStream(long)



openOutputStream
public OutputStream openOutputStream(long byteOffset) throws IOException(Code)



openPrim
public Connection openPrim(String name, int mode, boolean timeouts) throws IOException(Code)
Opens the file connection.
Parameters:
  name - URL path fragment
Parameters:
  mode - access mode
Parameters:
  timeouts - flag to indicate that timeouts allowed an opened Connection
throws:
  IOException - if some other kind of I/O error occurs.



openPrim
public Connection openPrim(SecurityToken token, String name) throws IOException(Code)
Opens the file connection and receive security token.
Parameters:
  token - security token from PIM
Parameters:
  name - URL path fragment an opened Connection
throws:
  IOException - if some other kind of I/O error occurs.



openPrim
public Connection openPrim(SecurityToken token, String name, int mode) throws IOException(Code)
Opens the file connection and receive security token.
Parameters:
  token - security token from PIM
Parameters:
  name - URL path fragment
Parameters:
  mode - access mode an opened Connection
throws:
  IOException - if some other kind of I/O error occurs.



readBytes
protected int readBytes(byte b, int off, int len) throws IOException(Code)
Reads up to len bytes of data from the input stream into an array of bytes, blocks until at least one byte is available.
Parameters:
  b - the buffer into which the data is read.
Parameters:
  off - the start offset in array bat which the data is written.
Parameters:
  len - the maximum number of bytes to read. the total number of bytes read into the buffer, or-1 if there is no more data because the end ofthe stream has been reached.
exception:
  IOException - if an I/O error occurs.



rename
public void rename(String newName) throws IOException(Code)



setFileConnection
public void setFileConnection(String fileName) throws IOException(Code)



setHidden
public void setHidden(boolean hidden) throws IOException(Code)



setReadable
public void setReadable(boolean readable) throws IOException(Code)



setWritable
public void setWritable(boolean writable) throws IOException(Code)



totalSize
public long totalSize()(Code)



truncate
public void truncate(long byteOffset) throws IOException(Code)



usedSize
public long usedSize()(Code)



writeBytes
protected int writeBytes(byte b, int off, int len) throws IOException(Code)
Writes len bytes from the specified byte array starting at offset off to this output stream.

Polling the native code is done here to allow for simple asynchronous native code to be written. Not all implementations work this way (they block in the native code) but the same Java code works for both.
Parameters:
  b - the data.
Parameters:
  off - the start offset in the data.
Parameters:
  len - the number of bytes to write. number of bytes written
exception:
  IOException - if an I/O error occurs. In particular,an IOException is thrown if the outputstream is closed.




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.