sdblib

utStream out)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    
    int nRead = 0;
    while ((nRead = in.read(buffer)) > 0) {
      out.write(buffer, 0, nRead);
    }
    tryFlush(new Flushable[] {out });
  }
  
  public static void redirect(InputStream in, OutputStream out, ISyncProgressMonitor monitor)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    
    int nRead = 0;
    while ((nRead = in.read(buffer)) > 0)
    {
      out.write(buffer, 0, nRead);
      monitor.advance(nRead);
    }
    tryFlush(new Flushable[] {out });
  }
  
  public static void redirect(Reader reader, Writer writer)
    throws IOException
  {
    char[] buffer = new char['?'];
    
    int nRead = 0;
    while ((nRead = reader.read(buffer)) > 0) {
      writer.write(buffer, 0, nRead);
    }
    tryFlush(new Flushable[] {writer });
  }
  
  public static void redirect(Reader reader, StringBuffer writer)
    throws IOException
  {
    char[] buffer = new char['?'];
    
    int nRead = 0;
    while ((nRead = reader.read(buffer)) > 0) {
      writer.append(buffer, 0, nRead);
    }
  }
  
  public static void redirect(Reader reader, StringBuilder writer)
    throws IOException
  {
    if (reader == null) {
      return;
    }
    char[] buffer = new char['?'];
    
    int nRead = 0;
    while ((nRead = reader.read(buffer)) > 0) {
      writer.append(buffer, 0, nRead);
    }
  }
  
  public static byte[] getBytes(InputStream in)
    throws IOException
  {
    return getBytes(in, false);
  }
  
  public static byte[] getBytes(InputStream in, boolean bClose)
    throws IOException
  {
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    try
    {
      redirect(in, byteOut);
      if (bClose) {
        tryClose(in);
      }
      return byteOut.toByteArray();
    }
    finally
    {
      tryClose(byteOut);
    }
  }
  
  public static String getString(Reader reader)
    throws IOException
  {
    return getString(reader, false);
  }
  
  /* Error */
  public static String getString(Reader reader, boolean bClose)
    throws IOException
  {
    // Byte code:
    //   0: new 27	java/lang/StringBuilder
    //   3: dup
    //   4: invokespecial 179	java/lang/StringBuilder:<init>	()V
    //   7: astore_2
    //   8: aload_0
    //   9: aload_2
    //   10: invokestatic 180	org/tizen/sdblib/util/IOUtil:redirect	(Ljava/io/Reader;Ljava/lang/StringBuilder;)V
    //   13: iload_1
    //   14: ifeq +7 -> 21
    //   17: aload_0
    //   18: invokestatic 162	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   21: aload_2
    //   22: invokevirtual 38	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   25: astore 4
    //   27: iconst_1
    //   28: anewarray 3	java/lang/Object
    //   31: dup
    //   32: iconst_0
    //   33: aload_2
    //   34: aastore
    //   35: invokestatic 182	org/tizen/sdblib/util/IOUtil:tryClose	([Ljava/lang/Object;)V
    //   38: aload 4
    //   40: areturn
    //   41: astore_3
    //   42: iconst_1
    //   43: anewarray 3	java/lang/Object
    //   46: dup
    //   47: iconst_0
    //   48: aload_2
    //   49: aastore
    //   50: invokestatic 182	org/tizen/sdblib/util/IOUtil:tryClose	([Ljava/lang/Object;)V
    //   53: aload_3
    //   54: athrow
    // Line number table:
    //   Java source line #390	-> byte code offset #0
    //   Java source line #392	-> byte code offset #8
    //   Java source line #394	-> byte code offset #13
    //   Java source line #396	-> byte code offset #17
    //   Java source line #399	-> byte code offset #21
    //   Java source line #402	-> byte code offset #27
    //   Java source line #403	-> byte code offset #33
    //   Java source line #399	-> byte code offset #38
    //   Java source line #402	-> byte code offset #41
    //   Java source line #403	-> byte code offset #48
    //   Java source line #404	-> byte code offset #53
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	55	0	reader	Reader
    //   0	55	1	bClose	boolean
    //   7	42	2	writer	StringBuilder
    //   41	13	3	localObject	Object
    //   25	14	4	str	String
    // Exception table:
    //   from	to	target	type
    //   8	27	41	finally
  }
  
  public static String getString(InputStream in)
    throws IOException
  {
    return getString(new InputStreamReader(in));
  }
  
  public static String getString(InputStream in, boolean bClose)
    throws IOException
  {
    return getString(new InputStreamReader(in), bClose);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.IOUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.OutputStream;

class Log$1
  extends OutputStream
{
  public void write(int b) {}
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.Log.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.tizen.sdblib.SmartDevelopmentBridge;

public class Log
{
  protected static final SimpleDateFormat FORMATTER = new SimpleDateFormat("hh:mm:ss");
  protected static PrintStream out;
  
  public static void v(String tag, String message)
  {
    println(LogLevel.VERBOSE, tag, message);
  }
  
  public static void d(String tag, String message)
  {
    println(LogLevel.DEBUG, tag, message);
  }
  
  public static void i(String tag, String message)
  {
    println(LogLevel.INFO, tag, message);
  }
  
  public static void w(String tag, String message)
  {
    println(LogLevel.WARN, tag, message);
  }
  
  public static void e(String tag, String message)
  {
    println(LogLevel.ERROR, tag, message);
  }
  
  public static void e(String tag, Throwable throwable)
  {
    if (throwable != null)
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      
      throwable.printStackTrace(pw);
      println(LogLevel.ERROR, tag, throwable.getMessage() + '\n' + sw.toString());
    }
  }
  
  private static void println(LogLevel logLevel, String tag, String message)
  {
    if (logLevel.getPriority() >= Preferences.getLogLevel().getPriority()) {
      printLog(logLevel, tag, message);
    }
  }
  
  public static void printLog(LogLevel logLevel, String tag, String message)
  {
    if (out == null)
    {
      try
      {
        String sdbPath = SmartDevelopmentBridge.getBridge().getSdbOsLocation();
        int lastIndex = sdbPath.lastIndexOf(File.separatorChar);
        String logPath = sdbPath.substring(0, lastIndex);
        
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd_HHmmss");
        if (logPath != null)
        {
          File file = new File(logPath);
          if ((file.exists()) && (file.isDirectory()))
          {
            String logDirectoryPath = logPath + File.separatorChar + "logs";
            File logDirectoryPathFile = new File(logDirectoryPath);
            if (!logDirectoryPathFile.exists()) {
              logDirectoryPathFile.mkdirs();
            }
            String fileName = logDirectoryPath + File.separatorChar + "sdblib-" + formatter.format(new Date()) + ".log";
            File logFile = new File(fileName);
            try
            {
              out = new PrintStream(new FileOutputStream(logFile, true));
            }
            catch (IOException e)
            {
              e.printStackTrace();
              System.out.println("Failed to write in log file:" + fileName);
            }
          }
        }
        if (out != null) {
          break label278;
        }
      }
      catch (Throwable e)
      {
        e.printStackTrace();
        System.out.println("Failed to make log file");
      }
      out = new PrintStream(new OutputStream()
      {
        public void write(int b) {}
      });
    }
    label278:
    String formatted = String.format("%s %c/%s: %s", new Object[] { FORMATTER.format(new Date()), Character.valueOf(logLevel.getLetter()), tag, message });
    out.println(formatted);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.Log
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

public enum LogLevel
{
  VERBOSE(
  
    2, "Verbose"),  DEBUG(3, "Debug"),  INFO(4, "Info"),  WARN(5, "Warning"),  ERROR(6, "Error"),  FATAL(7, "Fatal");
  
  private final int priority;
  private final String name;
  private char letter;
  
  private LogLevel(int priority, String name)
  {
    this.priority = priority;
    this.name = name;
    letter = name.charAt(0);
  }
  
  public static LogLevel getByName(String name)
  {
    LogLevel[] arrayOfLogLevel;
    int j = (arrayOfLogLevel = values()).length;
    for (int i = 0; i < j; i++)
    {
      LogLevel mode = arrayOfLogLevel[i];
      if (name.equalsIgnoreCase(name)) {
        return mode;
      }
    }
    return null;
  }
  
  public static LogLevel getByLetter(String val)
  {
    if (val.length() > 0)
    {
      char ch = val.charAt(0);
      LogLevel[] arrayOfLogLevel;
      int j = (arrayOfLogLevel = values()).length;
      for (int i = 0; i < j; i++)
      {
        LogLevel mode = arrayOfLogLevel[i];
        if (letter == ch) {
          return mode;
        }
      }
      return null;
    }
    return null;
  }
  
  public char getLetter()
  {
    return letter;
  }
  
  public int getPriority()
  {
    return priority;
  }
  
  public String getName()
  {
    return name;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.LogLevel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class MapUtil
{
  public static int length(Map<?, ?> map)
  {
    if (map == null) {
      return 0;
    }
    return map.size();
  }
  
  public static boolean isEmpty(Map<?, ?> map)
  {
    return length(map) == 0;
  }
  
  public static <K, V> Map<K, V> asMap(K[] keys, V[] values)
  {
    HashMap<K, V> map = new HashMap();
    if ((keys == null) || (values == null)) {
      return map;
    }
    int i = 0;
    for (int n = Math.min(keys.length, values.length); i < n; i++) {
      map.put(keys[i], values[i]);
    }
    return map;
  }
  
  public static <A, B> Map<A, B> asMap(Object[][] objs)
  {
    HashMap<A, B> map = new HashMap();
    int i = 0;
    for (int n = ArrayUtil.size(objs); i < n; i++) {
      if (2 == objs[i].length) {
        map.put(objs[i][0], objs[i][1]);
      }
    }
    return map;
  }
  
  public static void mergePropertiesIntoMap(Properties props, Map<Object, Object> map)
  {
    Assert.notNull(map);
    if (props == null) {
      return;
    }
    Enumeration<?> en = props.propertyNames();
    while (en.hasMoreElements())
    {
      String key = (String)en.nextElement();
      map.put(key, props.getProperty(key));
    }
  }
  
  public static String toString(Map<?, ?> map)
  {
    if (map == null) {
      return "<<null>>";
    }
    StringBuilder buffer = new StringBuilder();
    buffer.append("{");
    if (!map.isEmpty())
    {
      buffer.append("\n");
      for (Object key : map.keySet())
      {
        buffer.append("\t");
        buffer.append(key.toString());
        buffer.append("=");
        buffer.append(map.get(key));
        buffer.append("\n");
      }
    }
    buffer.append("}");
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.MapUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.SecureRandom;
import java.util.Arrays;

public class ObjectUtil
{
  public static <T> T nvl(T... args)
  {
    if (args == null) {
      return null;
    }
    Object[] arrayOfObject = args;int j = args.length;
    for (int i = 0; i < j; i++)
    {
      T arg = arrayOfObject[i];
      if (arg != null) {
        return arg;
      }
    }
    return null;
  }
  
  private static String hexServerIP = null;
  private static final SecureRandom SEEDER = new SecureRandom();
  
  public static boolean equals(Object obj1, Object obj2)
  {
    if (obj1 == obj2) {
      return true;
    }
    if ((obj1 == null) || (obj2 == null)) {
      return false;
    }
    if ((!obj1.getClass().isArray()) || (!obj2.getClass().isArray())) {
      return obj1.equals(obj2);
    }
    if (((obj1 instanceof boolean[])) && ((obj2 instanceof boolean[]))) {
      return Arrays.equals((boolean[])obj1, (boolean[])obj2);
    }
    if (((obj1 instanceof byte[])) && ((obj2 instanceof byte[]))) {
      return Arrays.equals((byte[])obj1, (byte[])obj2);
    }
    if (((obj1 instanceof char[])) && ((obj2 instanceof char[]))) {
      return Arrays.equals((char[])obj1, (char[])obj2);
    }
    if (((obj1 instanceof double[])) && ((obj2 instanceof double[]))) {
      return Arrays.equals((double[])obj1, (double[])obj2);
    }
    if (((obj1 instanceof float[])) && ((obj2 instanceof float[]))) {
      return Arrays.equals((float[])obj1, (float[])obj2);
    }
    if (((obj1 instanceof int[])) && ((obj2 instanceof int[]))) {
      return Arrays.equals((int[])obj1, (int[])obj2);
    }
    if (((obj1 instanceof long[])) && ((obj2 instanceof long[]))) {
      return Arrays.equals((long[])obj1, (long[])obj2);
    }
    if (((obj1 instanceof short[])) && ((obj2 instanceof short[]))) {
      return Arrays.equals((short[])obj1, (short[])obj2);
    }
    return false;
  }
  
  public static int getInt(byte[] bytes)
  {
    int i = 0;
    int j = 24;
    for (int k = 0; j >= 0; k++)
    {
      int l = bytes[k] & 0xFF;
      i += (l << j);
      j -= 8;
    }
    return i;
  }
  
  private static String padHex(String str, int length)
  {
    StringBuilder buffer = new StringBuilder();
    int j = 0;
    for (int n = length - str.length(); j < n; j++) {
      buffer.append('0');
    }
    buffer.append(str.subSequence(str.length() - Math.min(str.length(), length), str.length()));
    return buffer.toString();
  }
  
  public static String hexFormat(int i, int j)
  {
    String s = Integer.toHexString(i);
    return padHex(s, j);
  }
  
  public static final String generateGUID(Object obj)
  {
    StringBuilder guid = new StringBuilder(32);
    
    long timeNow = System.currentTimeMillis();
    int timeLow = (int)timeNow & 0xFFFFFFFF;
    guid.append(hexFormat(timeLow, 8));
    if (hexServerIP == null)
    {
      InetAddress localInetAddress = null;
      try
      {
        localInetAddress = InetAddress.getLocalHost();
      }
      catch (UnknownHostException localUnknownHostException1)
      {
        try
        {
          localInetAddress = InetAddress.getByName("localhost");
        }
        catch (UnknownHostException e)
        {
          e.printStackTrace();
          return null;
        }
      }
      byte[] serverIP = localInetAddress.getAddress();
      
      hexServerIP = hexFormat(getInt(serverIP), 8);
    }
    guid.append(hexServerIP);
    
    guid.append(hexFormat(System.identityHashCode(obj), 8));
    
    int node = -1;
    synchronized (SEEDER)
    {
      node = SEEDER.nextInt();
    }
    guid.append(hexFormat(node, 8));
    return guid.toString();
  }
  
  public static byte[] serialize(Object obj)
    throws IOException
  {
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    ObjectOutputStream objOut = new ObjectOutputStream(byteOut);
    objOut.writeObject(obj);
    return byteOut.toByteArray();
  }
  
  public static Object deserialize(byte[] bytes)
    throws IOException, ClassNotFoundException
  {
    Assert.notNull(bytes, "bytes must not be null");
    ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes);
    ObjectInputStream objIn = new ObjectInputStream(byteIn);
    return objIn.readObject();
  }
  
  public static String toString(Object obj)
  {
    if (obj == null) {
      return "<<null>>";
    }
    StringBuilder builder = new StringBuilder();
    builder.append(obj.getClass().getSimpleName());
    builder.append('@');
    int hash = obj.hashCode();
    for (int i = 8; i >= 0; i -= 8) {
      StringUtil.appendHexa(builder, 0xFF & hash >> i);
    }
    return builder.toString();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.ObjectUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

public class ParsingUtil
{
  protected static final Collection<String> BOOLEAN_TRUE = Collections.unmodifiableCollection(new HashSet(Arrays.asList(new String[] {
    "1", "yes", "y", "true", "t" })));
  protected static final Collection<String> BOOLEAN_FALSE = Collections.unmodifiableCollection(new HashSet(Arrays.asList(new String[] {
    "no, n", "false", "f", "0" })));
  
  public static boolean parseBoolean(String value, boolean defaultValue)
  {
    if (value == null) {
      return defaultValue;
    }
    String safe = StringUtil.trim(value).toLowerCase();
    return (defaultValue ? BOOLEAN_FALSE : BOOLEAN_TRUE).contains(safe) ^ defaultValue;
  }
  
  public static int parseInt(String value, int defaultValue)
  {
    if (value == null) {
      return defaultValue;
    }
    String trimmed = StringUtil.trim(value);
    return Integer.decode(trimmed).intValue();
  }
  
  public static long parseLong(String value, long defaultValue)
  {
    if (value == null) {
      return defaultValue;
    }
    String trimmed = StringUtil.trim(value);
    try
    {
      return Long.decode(trimmed).longValue();
    }
    catch (NumberFormatException localNumberFormatException) {}
    return defaultValue;
  }
  
  public static double parseDouble(String value, double defaultValue)
  {
    if (value == null) {
      return defaultValue;
    }
    String trimmed = StringUtil.trim(value);
    try
    {
      return Double.valueOf(trimmed).doubleValue();
    }
    catch (NumberFormatException localNumberFormatException) {}
    return defaultValue;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.ParsingUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

public class Preferences
{
  public static LogLevel DEFAULT_LOG_LEVEL = LogLevel.ERROR;
  private static int timeout = 5000;
  
  static
  {
    String defaultLevel = System.getProperty("default.sdblib.loglevel");
    if (defaultLevel != null)
    {
      LogLevel[] levels = LogLevel.values();
      try
      {
        int priority = Integer.parseInt(defaultLevel);
        LogLevel[] arrayOfLogLevel1;
        int j = (arrayOfLogLevel1 = levels).length;
        for (int i = 0; i < j; i++)
        {
          LogLevel level = arrayOfLogLevel1[i];
          if (level.getPriority() == priority) {
            DEFAULT_LOG_LEVEL = level;
          }
        }
      }
      catch (NumberFormatException localNumberFormatException)
      {
        LogLevel level = LogLevel.getByName(defaultLevel);
        if (level != null) {
          DEFAULT_LOG_LEVEL = level;
        }
      }
    }
  }
  
  private static LogLevel logLevel = DEFAULT_LOG_LEVEL;
  public static final int DEFAULT_TIMEOUT = 5000;
  
  public static LogLevel getLogLevel()
  {
    return logLevel;
  }
  
  public static void setLogLevel(String value)
  {
    LogLevel l = LogLevel.getByName(value);
    if (l == null) {
      return;
    }
    logLevel = l;
  }
  
  public static int getTimeOut()
  {
    return timeout;
  }
  
  public static void setTimeOut(int timeOut)
  {
    timeout = timeOut;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.Preferences
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

public class SdbShellProcess
  extends Process
{
  public Process process = null;
  public BufferedWriter bw = null;
  
  public SdbShellProcess(Process process, String command)
  {
    this.process = process;
    bw = new BufferedWriter(new OutputStreamWriter(this.process.getOutputStream()));
    try
    {
      bw.write(command + ";exit");
      bw.newLine();
      bw.flush();
    }
    catch (IOException e)
    {
      Log.e("sdb", "buffer write failed:" + e);
    }
  }
  
  /* Error */
  public void destroy()
  {
    // Byte code:
    //   0: iconst_3
    //   1: istore_1
    //   2: aload_0
    //   3: getfield 17	org/tizen/sdblib/util/SdbShellProcess:bw	Ljava/io/BufferedWriter;
    //   6: iload_1
    //   7: invokevirtual 87	java/io/BufferedWriter:write	(I)V
    //   10: aload_0
    //   11: getfield 17	org/tizen/sdblib/util/SdbShellProcess:bw	Ljava/io/BufferedWriter;
    //   14: invokevirtual 60	java/io/BufferedWriter:flush	()V
    //   17: ldc2_w 90
    //   20: invokestatic 92	java/lang/Thread:sleep	(J)V
    //   23: goto +158 -> 181
    //   26: astore_2
    //   27: ldc 63
    //   29: new 33	java/lang/StringBuilder
    //   32: dup
    //   33: ldc 65
    //   35: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   38: aload_2
    //   39: invokevirtual 67	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   42: invokevirtual 50	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   45: invokestatic 70	org/tizen/sdblib/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   48: aload_0
    //   49: getfield 17	org/tizen/sdblib/util/SdbShellProcess:bw	Ljava/io/BufferedWriter;
    //   52: invokevirtual 98	java/io/BufferedWriter:close	()V
    //   55: goto +160 -> 215
    //   58: astore 4
    //   60: ldc 63
    //   62: new 33	java/lang/StringBuilder
    //   65: dup
    //   66: ldc 101
    //   68: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   71: aload 4
    //   73: invokevirtual 67	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   76: invokevirtual 50	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   79: invokestatic 70	org/tizen/sdblib/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   82: goto +133 -> 215
    //   85: astore_2
    //   86: ldc 63
    //   88: new 33	java/lang/StringBuilder
    //   91: dup
    //   92: ldc 103
    //   94: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   97: aload_2
    //   98: invokevirtual 67	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   101: invokevirtual 50	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   104: invokestatic 70	org/tizen/sdblib/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   107: aload_0
    //   108: getfield 17	org/tizen/sdblib/util/SdbShellProcess:bw	Ljava/io/BufferedWriter;
    //   111: invokevirtual 98	java/io/BufferedWriter:close	()V
    //   114: goto +101 -> 215
    //   117: astore 4
    //   119: ldc 63
    //   121: new 33	java/lang/StringBuilder
    //   124: dup
    //   125: ldc 101
    //   127: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   130: aload 4
    //   132: invokevirtual 67	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   135: invokevirtual 50	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   138: invokestatic 70	org/tizen/sdblib/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   141: goto +74 -> 215
    //   144: astore_3
    //   145: aload_0
    //   146: getfield 17	org/tizen/sdblib/util/SdbShellProcess:bw	Ljava/io/BufferedWriter;
    //   149: invokevirtual 98	java/io/BufferedWriter:close	()V
    //   152: goto +27 -> 179
    //   155: astore 4
    //   157: ldc 63
    //   159: new 33	java/lang/StringBuilder
    //   162: dup
    //   163: ldc 101
    //   165: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   168: aload 4
    //   170: invokevirtual 67	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   173: invokevirtual 50	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   176: invokestatic 70	org/tizen/sdblib/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   179: aload_3
    //   180: athrow
    //   181: aload_0
    //   182: getfield 17	org/tizen/sdblib/util/SdbShellProcess:bw	Ljava/io/BufferedWriter;
    //   185: invokevirtual 98	java/io/BufferedWriter:close	()V
    //   188: goto +27 -> 215
    //   191: astore 4
    //   193: ldc 63
    //   195: new 33	java/lang/StringBuilder
    //   198: dup
    //   199: ldc 101
    //   201: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   204: aload 4
    //   206: invokevirtual 67	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   209: invokevirtual 50	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   212: invokestatic 70	org/tizen/sdblib/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   215: aload_0
    //   216: getfield 15	org/tizen/sdblib/util/SdbShellProcess:process	Ljava/lang/Process;
    //   219: invokevirtual 105	java/lang/Process:exitValue	()I
    //   222: pop
    //   223: goto +11 -> 234
    //   226: pop
    //   227: aload_0
    //   228: getfield 15	org/tizen/sdblib/util/SdbShellProcess:process	Ljava/lang/Process;
    //   231: invokevirtual 109	java/lang/Process:destroy	()V
    //   234: return
    // Line number table:
    //   Java source line #81	-> byte code offset #0
    //   Java source line #83	-> byte code offset #2
    //   Java source line #84	-> byte code offset #10
    //   Java source line #85	-> byte code offset #17
    //   Java source line #86	-> byte code offset #26
    //   Java source line #87	-> byte code offset #27
    //   Java source line #92	-> byte code offset #48
    //   Java source line #93	-> byte code offset #58
    //   Java source line #94	-> byte code offset #60
    //   Java source line #88	-> byte code offset #85
    //   Java source line #89	-> byte code offset #86
    //   Java source line #92	-> byte code offset #107
    //   Java source line #93	-> byte code offset #117
    //   Java source line #94	-> byte code offset #119
    //   Java source line #90	-> byte code offset #144
    //   Java source line #92	-> byte code offset #145
    //   Java source line #93	-> byte code offset #155
    //   Java source line #94	-> byte code offset #157
    //   Java source line #96	-> byte code offset #179
    //   Java source line #92	-> byte code offset #181
    //   Java source line #93	-> byte code offset #191
    //   Java source line #94	-> byte code offset #193
    //   Java source line #98	-> byte code offset #215
    //   Java source line #100	-> byte code offset #226
    //   Java source line #102	-> byte code offset #227
    //   Java source line #104	-> byte code offset #234
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	235	0	this	SdbShellProcess
    //   1	6	1	c	char
    //   26	13	2	e	IOException
    //   85	13	2	e	InterruptedException
    //   144	36	3	localObject	Object
    //   58	14	4	e	IOException
    //   117	14	4	e	IOException
    //   155	14	4	e	IOException
    //   191	14	4	e	IOException
    //   226	1	9	localIllegalThreadStateException	IllegalThreadStateException
    // Exception table:
    //   from	to	target	type
    //   2	23	26	java/io/IOException
    //   48	55	58	java/io/IOException
    //   2	23	85	java/lang/InterruptedException
    //   107	114	117	java/io/IOException
    //   2	48	144	finally
    //   85	107	144	finally
    //   145	152	155	java/io/IOException
    //   181	188	191	java/io/IOException
    //   215	223	226	java/lang/IllegalThreadStateException
  }
  
  public int exitValue()
  {
    return process.exitValue();
  }
  
  public InputStream getErrorStream()
  {
    return process.getErrorStream();
  }
  
  public InputStream getInputStream()
  {
    return process.getInputStream();
  }
  
  public OutputStream getOutputStream()
  {
    return process.getOutputStream();
  }
  
  public int waitFor()
    throws InterruptedException
  {
    return process.waitFor();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.SdbShellProcess
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import org.tizen.sdblib.daemon.AbstractServer;
import org.tizen.sdblib.daemon.ServerState;

public class StreamGobbler
  extends AbstractServer
{
  protected OutputStream os;
  protected StringBuffer buffer = new StringBuffer();
  protected BufferedReader br;
  
  public StreamGobbler(InputStream is)
  {
    this(is, null);
  }
  
  public StreamGobbler(InputStream is, OutputStream os)
  {
    this(null, is, os);
  }
  
  public StreamGobbler(String name, InputStream is, OutputStream os)
  {
    super(name);
    br = new BufferedReader(new InputStreamReader(is));
    this.os = os;
  }
  
  public String getResult()
  {
    return buffer.toString();
  }
  
  public void process()
  {
    try
    {
      String line = br.readLine();
      if (line == null)
      {
        setStatus(ServerState.Halting);
        return;
      }
      buffer.append(line);
      buffer.append("\n");
      if (os != null) {
        os.write((line + "\n").getBytes());
      }
      Log.d("gobbler", line);
    }
    catch (IOException ioe)
    {
      Log.e("sdb", "failed to read stream:" + ioe);
    }
  }
  
  protected void terminate()
  {
    IOUtil.tryClose(br);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.StreamGobbler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class StringUtil
{
  public static final String EMPTY_STRING = "";
  public static final String NULL_STRING = "<<null>>";
  public static final String EMPTY_BYTES_STRING = "<<EMPTY BYTES>>";
  public static final String LINE_SEPARATOR = System.getProperty("line.separator");
  public static final String TAB = "\t";
  protected static char CONTROL_CHARS_SHOWER = '.';
  protected static final char[] HEXA_CHARS = {
    '0', '1', '2', '3', '4', '5', '6', '7', 
    '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
  protected static final int N_INT_BY_BYTE = 4;
  protected static final int WIDTH_PER_LINE = 16;
  protected static char TWO_BYTES_CHARS_SHOWER = '?';
  
  public static InputStream toInputStream(String src)
  {
    if (src == null) {
      return null;
    }
    return new ByteArrayInputStream(src.getBytes());
  }
  
  public static String[] split(String str, String delimiters)
  {
    List<String> list = new ArrayList();
    StringTokenizer tokenizer = new StringTokenizer(str, delimiters);
    while (tokenizer.hasMoreTokens()) {
      list.add(tokenizer.nextToken());
    }
    return (String[])list.toArray(new String[0]);
  }
  
  public static String asString(Reader reader)
    throws IOException
  {
    StringBuilder sb = new StringBuilder();
    int c;
    while ((c = reader.read()) != -1)
    {
      int c;
      sb.append((char)c);
    }
    return sb.toString();
  }
  
  public static String asString(InputStream is)
    throws IOException
  {
    StringBuffer out = new StringBuffer();
    byte[] b = new byte['?'];
    int n;
    while ((n = is.read(b)) != -1)
    {
      int n;
      out.append(new String(b, 0, n));
    }
    return out.toString();
  }
  
  public static String removeEnd(String str, String remove)
  {
    if ((isEmpty(str)) || (isEmpty(remove))) {
      return str;
    }
    if (str.endsWith(remove)) {
      return str.substring(0, str.length() - remove.length());
    }
    return str;
  }
  
  public static String removeStart(String str, String remove)
  {
    if ((isEmpty(str)) || (isEmpty(remove))) {
      return str;
    }
    if (str.startsWith(remove)) {
      return str.substring(remove.length());
    }
    return str;
  }
  
  public static void appendHexa(StringBuilder buffer, int ch)
  {
    if (ch < 16)
    {
      buffer.append('0');
      buffer.append(HEXA_CHARS[(0xF & ch)]);
    }
    else
    {
      buffer.append(HEXA_CHARS[(0xF & ch >> 4)]);
      buffer.append(HEXA_CHARS[(0xF & ch)]);
    }
  }
  
  protected static void lineEnd(StringBuilder hexPart, StringBuilder textPart, StringBuilder ret)
  {
    hexPart.append("     |");
    
    textPart.append("|\n");
    
    ret.append(hexPart);
    ret.append(textPart);
    
    hexPart.delete(0, hexPart.capacity());
    textPart.delete(0, textPart.capacity());
  }
  
  public static String text2hexa(byte[] data)
  {
    if (data == null) {
      return "<<null>>";
    }
    return text2hexa(data, 0, data.length);
  }
  
  public static String text2hexa(byte[] data, int offset, int length)
  {
    if (data == null) {
      return "<<null>>";
    }
    if (data.length <= 0) {
      return "<<EMPTY BYTES>>";
    }
    ByteArrayInputStream reader = new ByteArrayInputStream(data, offset, length);
    StringBuilder ret = new StringBuilder();
    StringBuilder hexPart = new StringBuilder();
    StringBuilder textPart = new StringBuilder();
    
    int address = 0;
    int ch = -1;
    int printByte = 0;
    int cnt = 0;
    
    hexPart.append("          ");
    
    int i = 0;
    for (int n = 4; i < n; i++)
    {
      hexPart.append("+-------");
      textPart.append("+---");
    }
    lineEnd(hexPart, textPart, ret);
    while ((ch = reader.read()) >= 0)
    {
      if (cnt == 0)
      {
        for (int i = 3; i >= 0; i--)
        {
          printByte = 0xFF & address >> 8 * i;
          appendHexa(hexPart, printByte);
        }
        hexPart.append("  ");
        address += 16;
      }
      appendHexa(hexPart, ch);
      if (((ch & 0x80) != 0) || (ch < 32)) {
        textPart.append(CONTROL_CHARS_SHOWER);
      } else {
        textPart.append((char)ch);
      }
      cnt++;
      if (16 == cnt)
      {
        lineEnd(hexPart, textPart, ret);
        cnt = 0;
      }
    }
    if (cnt != 0)
    {
      for (; cnt < 16; cnt++)
      {
        hexPart.append("  ");
        textPart.append(' ');
      }
      lineEnd(hexPart, textPart, ret);
    }
    return ret.toString();
  }
  
  public static boolean isEmpty(CharSequence str)
  {
    if (str == null) {
      return true;
    }
    int i = 0;
    for (int n = str.length(); i < n; i++) {
      if (!Character.isWhitespace(str.charAt(i))) {
        return false;
      }
    }
    return true;
  }
  
  public static int size(CharSequence str)
  {
    if (str == null) {
      return 0;
    }
    return str.length();
  }
  
  public static boolean hasLength(CharSequence str)
  {
    return size(str) > 0;
  }
  
  public static boolean hasText(CharSequence str)
  {
    return !isEmpty(str);
  }
  
  public static String nvl(String... strs)
  {
    String val = (String)ObjectUtil.nvl(strs);
    if (val == null) {
      return "";
    }
    return val;
  }
  
  public static String trimLeading(String str)
  {
    if (!hasLength(str)) {
      return str;
    }
    char[] chs = str.toCharArray();
    int i = 0;
    for (int n = chs.length; i < n; i++) {
      if (!Character.isWhitespace(chs[i])) {
        return new String(chs, i, str.length() - i);
      }
    }
    return "";
  }
  
  public static String trimTrailing(String str)
  {
    if (!hasLength(str)) {
      return str;
    }
    char[] chs = str.toCharArray();
    int i = chs.length - 1;
    for (int j = chs.length; j > 0; j--)
    {
      if (!Character.isWhitespace(chs[i])) {
        return new String(chs, 0, j);
      }
      i--;
    }
    return "";
  }
  
  public static String trim(String str)
  {
    return trimTrailing(trimLeading(str));
  }
  
  public static String getMeaningful(String str)
  {
    if (str == null) {
      return "";
    }
    return trim(str).toLowerCase();
  }
  
  public static String mask(String str, String maskingStr)
  {
    if (str == null) {
      return "null";
    }
    StringBuilder buffer = new StringBuilder();
    int i = 0;
    for (int n = str.length(); i < n; i++) {
      buffer.append(maskingStr);
    }
    return buffer.toString();
  }
  
  public static String getParamater(String str, char delimeter, int escaper, int targetIndex)
    throws IOException
  {
    try
    {
      if (str == null) {
        return null;
      }
      StringReader reader = new StringReader(str);
      StringWriter writer = null;
      int ch = 0;
      
      int status = 0;
      int index = 0;
      if (targetIndex == 0) {
        writer = new StringWriter();
      }
      while ((ch = reader.read()) >= 0)
      {
        if (1 == status)
        {
          status = 0;
        }
        else
        {
          if (escaper == ch)
          {
            status = 1;
            continue;
          }
          if (delimeter == ch)
          {
            if (index == targetIndex) {
              return writer.toString();
            }
            index++;
            if (index != targetIndex) {
              continue;
            }
            writer = new StringWriter();
            
            continue;
          }
        }
        if (writer != null) {
          writer.write(ch);
        }
      }
      if (index == targetIndex) {
        return writer.toString();
      }
      return null;
    }
    catch (IOException e)
    {
      throw new IllegalStateException(e);
    }
  }
  
  public static String lastSubstring(String str, int indexFromLast)
  {
    if (str == null) {
      return null;
    }
    int length = str.length();
    if (length < indexFromLast) {
      return str;
    }
    return str.substring(length - indexFromLast);
  }
  
  public static String getLastSegment(String str, String separator)
  {
    if (str == null) {
      return "";
    }
    int index = str.lastIndexOf(separator);
    if (index < 0) {
      return str;
    }
    return str.substring(index + separator.length());
  }
  
  public static String removeLastSegment(String str, String separator)
  {
    if (str == null) {
      return "";
    }
    int index = str.lastIndexOf(separator);
    if (index < 0) {
      return "";
    }
    return str.substring(0, index);
  }
  
  public static String multiply(String symbol, int n)
  {
    if (symbol == null) {
      return "";
    }
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < n; i++) {
      buffer.append(symbol);
    }
    return buffer.toString();
  }
  
  public static boolean containsWhitespace(CharSequence str)
  {
    int nChar = size(str);
    for (int i = 0; i < nChar; i++) {
      if (Character.isWhitespace(str.charAt(i))) {
        return true;
      }
    }
    return false;
  }
  
  public static String trimLeadingCharacter(String str, char leadingCharacter)
  {
    if (!hasLength(str)) {
      return str;
    }
    char[] chs = str.toCharArray();
    int i = 0;
    for (int n = chs.length; i < n; i++) {
      if (leadingCharacter != chs[i]) {
        return new String(chs, i, str.length() - i);
      }
    }
    return "";
  }
  
  public static String trimTrailingCharacter(String str, char trailingCharacter)
  {
    if (!h
1 2 3 4 5 6 7

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd