Results 1 to 6 of 6
  1. #1
    mikezang is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default How to make adapter class between FileConnection and StorageConnection?

    There are a lot of J2ME applications that use JSR75 file system (javax.microedition.io.file.FileConnection interface).
    My device (made by Softbank Mobile) supports file system, but use a different interface com.j_phone.io.StorageConnection.

    I want to know how can I make a class or interface (base on adapter design pattern) between these two interface? so that I can use original source without any modified.

    javax.microedition.io.file.FileConnection Method Summary
    Java Code:
    long 	availableSize()
     boolean 	canRead()
     boolean 	canWrite()
     void 	create()
     void 	delete()
     long 	directorySize(boolean includeSubDirs)
     boolean 	exists()
     long 	fileSize()
     java.lang.String 	getName()
     java.lang.String 	getPath()
     java.lang.String 	getURL()
     boolean 	isDirectory()
     boolean 	isHidden()
     boolean 	isOpen()
     long 	lastModified()
     java.util.Enumeration 	list()
     java.util.Enumeration 	list(java.lang.String filter, boolean includeHidden)
     void 	mkdir()
     java.io.DataInputStream 	openDataInputStream()
     java.io.DataOutputStream 	openDataOutputStream()
     java.io.InputStream 	openInputStream()
     java.io.OutputStream 	openOutputStream()
     java.io.OutputStream 	openOutputStream(long byteOffset)
     void 	rename(java.lang.String newName)
     void 	setFileConnection(java.lang.String fileName)
     void 	setHidden(boolean hidden)
     void 	setReadable(boolean readable)
     void 	setWritable(boolean writable)
     long 	totalSize()
     void 	truncate(long byteOffset)
     long 	usedSize()
     
    Methods inherited from interface javax.microedition.io.Connection
    close
    com.j_phone.io.StorageConnection Method Summary
    Java Code:
    void 	close()
     boolean 	createFolder()
     boolean 	delete()
     boolean 	exists()
     java.lang.String 	getApplicationDescription(java.lang.String attribute)
     java.lang.String 	getCopyrightedDataContentType()
     java.lang.String 	getCopyrightedDataHeader(java.lang.String name)
     int 	getCopyrightedDataVersion()
     long 	getLength()
     int 	getType()
     java.lang.String 	getTypeString()
     boolean 	isCopyrighted()
     boolean 	isFile()
     boolean 	isFolder()
     java.lang.String[] 	list()
     InputRandomAccess 	openInputRandomAccess()
     java.io.InputStream 	openInputStream()
     java.io.OutputStream 	openOutputStream()
     boolean 	renameTo(java.lang.String newName)
     
    Methods inherited from javax.microedition.io.InputConnection
    openDataInputStream
     
    Methods inherited from javax.microedition.io.OutputConnection
    openDataOutputStream

  2. #2
    Join Date
    Aug 2009
    Posts
    17
    Rep Power
    0

    Default

    Hi,

    Your discription is not clear, Please explain what you exactly wants to do.

    Thanks
    Abhijeet Namdeo

  3. #3
    mikezang is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default

    Well as you know there is a interface javax.microedition.io.file.FileConnection (JSR75) that is used widely, this is what I said one interface.

    Then in my device, there is a similar File Access interface com.j_phone.io.StorageConnection, I am sorry it seems there is no English JavaDoc.

    Although they are not the whole same, but most of methods are similar.

    When I port a application that used FileConenction to my device, I have to change all FileConnection to StorageConnection and modify some methods.

    I want to know if I can make a adapter class between these two interface, so that I don't need to modify every time when I port applications.

    May I make sense? I can explain again if you are still not clear.

  4. #4
    Join Date
    Aug 2009
    Posts
    17
    Rep Power
    0

    Default

    Hi,

    You can use abstract class for interaction with interface also this class will work as an adapter.
    Last edited by abhijeetrajenamdeo; 08-07-2009 at 10:51 AM.

  5. #5
    mikezang is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default

    I am not sure how to do, do you have any detail suggestion?

    Any way is ok even if not use adapter design pattern.
    I just thought design pattern is good at this purpose.

  6. #6
    Join Date
    Aug 2009
    Posts
    17
    Rep Power
    0

    Default

    Hi Mike,

    If you can explain your project then it should be easy to make design of classes.

Similar Threads

  1. Hints on how to make a Java Class
    By luron31 in forum New To Java
    Replies: 11
    Last Post: 07-09-2009, 05:31 AM
  2. How to using read file in FileConnection
    By bbonya in forum Sun Java Wireless Toolkit
    Replies: 2
    Last Post: 06-23-2008, 02:01 AM
  3. Replies: 3
    Last Post: 06-22-2008, 07:25 PM
  4. Please help, need to make my class static.
    By sumak in forum New To Java
    Replies: 1
    Last Post: 04-19-2008, 07:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •