com.pepper.platform.util
Class Env

java.lang.Object
  extended by com.pepper.platform.util.Env

public class Env
extends Object

Env contains environment helper methods. Pad has a generic architecture designation isPadOS() This is further qualified when necessary as Pad 2 or Pad 3. The -dPAD*=true properties could be used to force an override, like on a non-pad linux box. isPad returns true for Pad 2 and Pad 3, or when PAD=true isPad2 only for Pad 2, based on value of os.arch="arm" or PAD2=true isPad3 only for Pad 3, based on os.version including "geode" or PAD3=true Otherwise its a PC OS is determined by the value of os.name

See Also:
for corresponding values used in XML pages and XSL tests

Field Summary
static int DOCUMENTS
           
static int DOWNLOADS
           
static int EBOOKS
           
static int HOME
           
static int MUSIC
           
static String PAD_CARD
          Path for Pad SD/MMC card
static String PAD_DROPBOX
          Path for Pad drop box
static String PAD_HOME
          Path for Pad home dir
static String PAD_NETWORK
          Path for Pad mounted network device
static String PAD_PROPERTY
           
static String PAD_USB
          Path for Pad USB device
static String PAD2_PROPERTY
           
static String PAD3_PROPERTY
           
static String PEPPER_PROTOCOL
          Pepper Protocol Prefix.
static int PICTURES
           
static int VIDEO
           
 
Constructor Summary
Env()
           
 
Method Summary
static String getArch()
          The current architecture Used for matching in page transformations
static String getDefaultUserDirectory(int dirType)
          Get user's default directory path.
static String[] getDirs()
          Return the list of valid directories
static String[] getEnv()
          This Linux-only function returns a subset of the Keeper's process environment.
static String getFileURL(String filePath)
          Returns a File URL appropriate for the specified path.
static String getFileURLPrefix(String filePath)
          Returns a File URL prefix appropriate for the specified path.
static String getJarURLPrefix(String filePath)
          Returns a Jar File URL prefix appropriate for the specified path.
static String getPepperURL(String filePath)
          Returns a Pepper URL appropriate for the specified path.
static String getSerialNumber()
          Get the serial number for this Pad
static void initialize()
          Initialize frequently used booleans
static boolean isLinuxOS()
          Returns true if called on a Linux system.
static boolean isMacOS()
          Returns true if called on an OS X system.
static boolean isPad2()
          Returns true if called on the Pepper Pad 2.
static boolean isPad3()
          Returns true if called on the Pepper Pad 3.
static boolean isPad3OrLinux()
          Returns true if called on Pad 3 or a Linux environment that is NOT Pad2
static boolean isPadOS()
          Returns true if called on the Pepper Pad.
static boolean isWindows()
          Returns true if called on a Window system.
static String makePepperURL(String resourceId, String sectionId, String packageId, boolean isPage)
          Creates a string representing a pepper url
static URL makeThePepperURL(String resourceId, String sectionId, String packageId, boolean isPage)
          Make Pepper URL and return it as a URL
static void populateDirectoryNames(MessageCatalog catalog)
          Load default directory names for each platform from the message catalog.
static String removeFileURL(String filePath)
          Removes the File URL from the specified path and returns the result.
static String removePepperURL(String s)
          Returns a String by removing the Pepper URL prefix from the passed in String.
static boolean startsWithFileURL(String filePath)
          Returns true if the filePath starts with a file URL.
static boolean startsWithPepperURL(String filePath)
          Returns true if the filePath starts with a Pepper URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAD_HOME

public static final String PAD_HOME
Path for Pad home dir

See Also:
Constant Field Values

PAD_CARD

public static final String PAD_CARD
Path for Pad SD/MMC card

See Also:
Constant Field Values

PAD_USB

public static final String PAD_USB
Path for Pad USB device

See Also:
Constant Field Values

PAD_NETWORK

public static final String PAD_NETWORK
Path for Pad mounted network device

See Also:
Constant Field Values

PAD_DROPBOX

public static final String PAD_DROPBOX
Path for Pad drop box

See Also:
Constant Field Values

PAD_PROPERTY

public static final String PAD_PROPERTY
See Also:
Constant Field Values

PAD2_PROPERTY

public static final String PAD2_PROPERTY
See Also:
Constant Field Values

PAD3_PROPERTY

public static final String PAD3_PROPERTY
See Also:
Constant Field Values

PEPPER_PROTOCOL

public static final String PEPPER_PROTOCOL
Pepper Protocol Prefix.

See Also:
Constant Field Values

HOME

public static final int HOME
See Also:
Constant Field Values

PICTURES

public static final int PICTURES
See Also:
Constant Field Values

MUSIC

public static final int MUSIC
See Also:
Constant Field Values

VIDEO

public static final int VIDEO
See Also:
Constant Field Values

DOWNLOADS

public static final int DOWNLOADS
See Also:
Constant Field Values

EBOOKS

public static final int EBOOKS
Since:
3.2
See Also:
Constant Field Values

DOCUMENTS

public static final int DOCUMENTS
Since:
3.2
See Also:
Constant Field Values
Constructor Detail

Env

public Env()
Method Detail

initialize

public static void initialize()
Initialize frequently used booleans


getEnv

public static String[] getEnv()
This Linux-only function returns a subset of the Keeper's process environment. It is used by other code in the system for calls to Runtime.exec(), allowing such code to pass a minimal environment to the new process. The primary purpose of this is to allow new executables to be launched without LD_PRELOAD set which causes latency in startup of the new process. The environment variables that are set by this call are: DISPLAY HOME LD_LIBRARY_PATH PATH Note - new environment variables should only be added to this method only if they are truly global and apply to multiple applications. Otherwise, they should be added to the to the local copy of the env before it's passed to the Runtime exec call.

Returns:
an array of String instances of the form: NAME=VALUE, or null if the OS is not Linux.

isLinuxOS

public static boolean isLinuxOS()
Returns true if called on a Linux system.

Returns:
a boolean value.

isMacOS

public static boolean isMacOS()
Returns true if called on an OS X system.

Returns:
a boolean value.

isWindows

public static boolean isWindows()
Returns true if called on a Window system.

Returns:
a boolean value.

isPadOS

public static boolean isPadOS()
Returns true if called on the Pepper Pad.

Returns:
a boolean value.

isPad2

public static boolean isPad2()
Returns true if called on the Pepper Pad 2.

Returns:
a boolean value.

isPad3

public static boolean isPad3()
Returns true if called on the Pepper Pad 3.

Returns:
a boolean value.

isPad3OrLinux

public static boolean isPad3OrLinux()
Returns true if called on Pad 3 or a Linux environment that is NOT Pad2

Returns:
a boolean value
Since:
3.2

getArch

public static String getArch()
The current architecture Used for matching in page transformations

Returns:
String value fo the architecture - ie. pad, pc
See Also:
PageXML

makePepperURL

public static String makePepperURL(String resourceId,
                                   String sectionId,
                                   String packageId,
                                   boolean isPage)
Creates a string representing a pepper url

Parameters:
resourceId - string
sectionId - string
packageId - string
isPage - boolean

makeThePepperURL

public static URL makeThePepperURL(String resourceId,
                                   String sectionId,
                                   String packageId,
                                   boolean isPage)
                            throws MalformedURLException
Make Pepper URL and return it as a URL

Parameters:
resourceId - a String value
sectionId - a String value
packageId - a String value
isPage - a boolean value
Returns:
an URL value
Throws:
MalformedURLException - if an error occurs

removePepperURL

public static String removePepperURL(String s)
Returns a String by removing the Pepper URL prefix from the passed in String.

Parameters:
s - the String to convert.

getPepperURL

public static String getPepperURL(String filePath)
Returns a Pepper URL appropriate for the specified path.

Parameters:
filePath - the path to the file.

startsWithPepperURL

public static boolean startsWithPepperURL(String filePath)
Returns true if the filePath starts with a Pepper URL.

Parameters:
filePath - the path to the file.
Returns:
true if the filePath starts with a Pepper URL.

getFileURLPrefix

public static String getFileURLPrefix(String filePath)
Returns a File URL prefix appropriate for the specified path.

Parameters:
filePath - the path to the file.

getJarURLPrefix

public static String getJarURLPrefix(String filePath)
Returns a Jar File URL prefix appropriate for the specified path.

Parameters:
filePath - the path to the file.

getFileURL

public static String getFileURL(String filePath)
Returns a File URL appropriate for the specified path.

Parameters:
filePath - the path to the file.

startsWithFileURL

public static boolean startsWithFileURL(String filePath)
Returns true if the filePath starts with a file URL.

Parameters:
filePath - the path to the file.
Returns:
true if the filePath starts with a file URL.

removeFileURL

public static String removeFileURL(String filePath)
Removes the File URL from the specified path and returns the result.

Parameters:
filePath - the path to clip.
Returns:
the clipped path.

getDefaultUserDirectory

public static String getDefaultUserDirectory(int dirType)
Get user's default directory path.

Parameters:
dirType: - HOME, PICTURES, MUSIC, VIDEO, DOWNLOADS, EBOOKS, DOCUMENTS
Returns:
String directory path

populateDirectoryNames

public static void populateDirectoryNames(MessageCatalog catalog)
Load default directory names for each platform from the message catalog. This method must be called before accessing LINUX_DIRS, MAC_DIRS, etc.

Parameters:
catalog - MessageCatalog containing localized directory names.

getDirs

public static String[] getDirs()
Return the list of valid directories

Returns:
String[] containing the dirctory names of the form "/name"

getSerialNumber

public static String getSerialNumber()
Get the serial number for this Pad

Returns:
String serial number
Since:
3.2


Copyright © 2006-2007 Pepper Computer, Inc. All Rights Reserved.