Sunday, March 16, 2014

JavaSE: How to SET/GET your own Files and Directory Attributes

In the previous article "Determining Views Supported by a Particular File System" and see how to ask the file system store, and see supportability of a particular file attribute view.

We are going to explore in a nutshell, one of the most advanced and important files attribute views which is User-Defined File Attributes View.

Particularly, I am using this feature a lot in my exchanged files during integration between my systems, to hide my files meta-data and security related information from users and contents of the file. So the file content will be only regarding the content of the file only, no more irrelevant meta-data.

Therefore If you find that there are not enough built-in attributes for your needs or if you have some unique meta-data (meaningful to the file system) that you want to associate with a file, you can define your own attributes.

NIO.2 offers the user-defined file attributes view, extended attributes through the UserDefinedFileAttributeView interface. This facility allows you to associate to a file any attribute that you consider to be useful for your use cases.

Here you should know how to:

  1. Check User-Defined Attributes Supportability
  2. Operations on User-Defined Attributes as the following:
    1. Define a User Attribute.
    2. List User-Defined Attribute Names and Value Sizes.
    3. Get the Value of a User-Defined Attribute.
    4. Delete a File’s User-Defined Attribute.

Here is the class that has operations defined previously, also you need to use JDK 7+:


References


Thursday, March 13, 2014

JavaSE 7,8: Determining Views Supported by a Particular File System

If you have questions about a file or a directory, such as whether it is hidden, whether it is a directory, what its size is, and who owns it, you can get answers to those questions (and many others) from the metadata, which is data about other data.

NIO.2 associates the notion of metadata with attributes and provides access to them through the java.nio.file.attribute package. Since different file systems have different notions about which attributes should be tracked, NIO.2 groups the attributes into views, each of which maps to a particular file system implementation.

Generally, views provide the attributes in bulk through a common method, readAttributes(). In addition, you can extract and set a single attribute with the getAttribute() and setAttribute() methods, respectively, which are available in the java.nio.file.Files class. Depending On the view, other methods are available for additional tasks.

Here i will explain how with NIO.2 you can manage more details about files’ metadata than ever before. Attributes are divided into categories, and now they cover POSIX systems as well.

Before you attempt to access a view's attributes, make sure that your file system supports the corresponding view.

NIO.2 comes with a set of six views (Basic, Dos, POSIX, FileOwner, ACL and UserDefinedFileAttributeView).
  • POSIX (Portable Operating System Interface for UNIX).
  • All file systems support the basic view, so you should get at least the basic name in your output.

The supported views are:

  1. BasicFileAttributeView
    This is a view of basic attributes that must be supported by all file system implementations. The attribute view name is basic.
  2. DosFileAttributeView
    This view provides the standard four supported attributes on file systems that support the DOS attributes. The attribute view name is dos.
  3. PosixFileAttributeView
    This view extends the basic attribute view with attributes supported on file systems that support the POSIX (Portable Operating System Interface for Unix) family of standards, such as Unix. The attribute view name is posix.
  4. FileOwnerAttributeView
    This view is supported by any file system implementation that supports the concept of a file owner. The attribute view name is owner.
  5. AclFileAttributeView
    This view supports reading or updating a file’s ACL. The NFSv4 ACL model is supported. The attribute view name is acl.
  6. UserDefinedFileAttributeView
    This view enables support of metadata that is user defined.

Here are code snipets that shows different operations

  • Get all supported file system views

  • Check if the file store support a specific view
    You can test a particular view on a file store by calling the FileStore.supportsFileAttributeView() method. You can pass the desired view as a String or as a class name.

  • Check if a file store in which a particular file resides supports a single view
    Moreover, you can check if a file store in which a particular file resides supports a single view.


That all, have fun, if you like it share it.

Refrences:

Sunday, March 2, 2014

Creating right mobile icons sizes for Android, iOS and Windows applications.

I am developing a mobile application that will serve all Egyptians people for a critical national project.

It a service and management based mobile application which is related to Fuel locations finder and Customers fuel subsidy management card System.

It will be released soon by the middle of March in Google play for Android platform and by the end of March 2014 in Apple App Store for iOS application, followed by windows mobile platform in May 2014.

It is a hybrid mobile development rather than native development.

While designing the application I have faced many challenges performance, design, Architecture, cross-platform development, and Graphics especially the logo design. Designing icons especially for iOS platforms is a tricky a little bit.

There are different icons sizes related to resolution (normal and Retina’s displays), places, and naming conventions for applications targeting iOS 3, 4, 6, and 7.

However, it was easier developing the icons for Android platform, but anyway I will share icons sizes for both platforms. and Microsoft Windows mobile platform as well.

It is a good idea and practice to develop

the larger icon size first then export it to different sizes. I used Adobe Photoshop and Illustrator CC. Illustrator is a great tool for logos because it is vector based, so scaling the artwork are easier to scale without losing the artwork resolution.

Android platform

The following table show different icons for different displays resolutions in pixel:


Display


Launcher Icons


Action Bar Icons


Google Play


512x512


---


Double Extra High dpi (xhdpi)


---


96x96


Extra High dpi (xhdpi)


96x96


64x64


High dpi (hdpi)


72x72


48x48


Medium dpi (mdpi)


48x48


36x36


Low dpi (ldpi)


36x36


---

iOS platform

The following table shows different icons for different iDevices displays resolutions in pixel, note that iOS 7 iPhone and iPod has Retina's display support only, as all iOS 7 supported iDevices are iPhone from 4 to 5s, and 5th generation iPod touch.


OS/ Device/ Place


Standard Resolution


High Resolution (Retina Display)


iPhone and iPod Touch


iPad


iPhone and iPod Touch


iPad


iOS 6 platform


Home Screen Icon


57x57


72x72


114x114


144x144


Settings Icon


29x29


29x29


58x58


58x58


Spotlight Icon


29x29


100x100


58x58


50x50


App icon for the App Stores


1024x1024


512x512


1024x1024


1024x1024


iOS 7 platform


Home Screen Icon


---


76x76


120x120


152x152


Settings Icon


---


29x29


58x58


58x58


Spotlight Icon


---


80x80


80x80


40x40


App icon for the App Stores


---


512x512


1024x1024


1024x1024

Windows Phone

The following table shows different resolutions in pixel for Microsoft windows platform application and marketplace icons:


Application Place


Icon Size


Application


Icon


62x62


Tile Image


173x173


Marketplace


Application icon for Windows Phone Marketplace catalog (small)


99x99


Application icon for Windows Phone Marketplace catalog (large)


173x173


Desktop application icon for Windows Phone Marketplace catalog


200x200