Android Open Source - andro_auto_framework Properties Reader






From Project

Back to project page andro_auto_framework.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project andro_auto_framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.imaginea.botbot.filereader;
/*from w  w  w.  j a  va2 s  .c  o m*/
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;

import org.testng.Assert;

public class PropertiesReader implements BaseReader {

  Properties propLocator = new Properties();

  @Override
  public void loadReaderFile(String filePath) {
    File locatorFile = new File(filePath);
    try {
    this.openFile(locatorFile);
    }catch(Exception e){
      System.out.println(e.toString());
      Assert.fail("Unable to open file : " + filePath);
    }

  }
  
  public void openFile(File file) throws Exception {
    boolean result = true;
    HashMap<String, String> hm = new HashMap<String, String>();
    FileInputStream fin= new FileInputStream(file);
    if (propLocator.isEmpty()) {
      try {
        propLocator.load(fin);

      } catch (IOException e) {
        System.out.println(e.toString());
      }
    } else {
      Properties tempProp = new Properties();
      try {
        tempProp.load(fin);
      } catch (IOException e) {
        System.out.println(e.toString());
      }
      for (Enumeration e = tempProp.keys(); e.hasMoreElements();) {
        String key = (String) e.nextElement();
        if (propLocator.containsKey(key)) {
          result = false;
          hm.put(key, tempProp.getProperty(key, ""));

        }
      }
      if (!result) {
        throw new Exception(
            "Duplicate entries found in the properties file. Following are the values: \n"
                + hm.toString());
      }else{
        propLocator.load(fin);
      }
    }

  }

  @Override
  public void openFile(String fileName) {
    File file= new File(fileName);
    try {
      this.openFile(file);
      }catch(Exception e){
        System.out.println(e.toString());
      }
  }

  @Override
  public String getDataForKey(String key) {
    String data=propLocator.getProperty(key, "");
    if(data.equalsIgnoreCase("")){
      Assert.fail("Key not found for property: "+ key);
    }
    return data;

  }

  @Override
  public void storeKeyValue(String locatorName, String newLocator) {
    propLocator.setProperty(locatorName, newLocator);

  }

  @Override
  public void modifyValueForKey(String locatorName, String newLocatorValue) {
    propLocator.setProperty(locatorName, newLocatorValue);

  }

  @Override
  public boolean supportsFileType(String filePath) {
    if ((new File(filePath).isFile()) && filePath.endsWith(".properties")) {
      return true;
    } else {
      return false;
    }

  }
  

}




Java Source Code List

com.imaginea.botbot.server.converter.RecordEntriesConverter.java
com.imaginea.botbot.server.converter.RecordEntryConverter.java
com.imaginea.botbot.server.converter.RecordSessionConverter.java
com.imaginea.botbot.server.converter.RecordSessionsConverter.java
com.imaginea.botbot.server.converter.UriResolver.java
com.imaginea.botbot.server.jpa.RecordEntry.java
com.imaginea.botbot.server.jpa.RecordSession.java
com.imaginea.botbot.server.service.PersistenceService.java
com.imaginea.botbot.server.service.RecordEntriesResource.java
com.imaginea.botbot.server.service.RecordEntryResource.java
com.imaginea.botbot.server.service.RecordSessionResource.java
com.imaginea.botbot.server.service.RecordSessionsResource.java
com.imaginea.botbot.server.servlet.DownloadCsv.java
com.zutubi.android.junitreport.JUnitReportListener.java
com.zutubi.android.junitreport.JUnitReportTestRunner.java
com.zutubi.android.junitreport.TestKeeper.java
com.zutubi.android.junitreport.TestngReportListener.java
org.imaginea.botbot.CommandTransmitter.java
org.imaginea.botbot.Command.java
org.imaginea.botbot.Convertor.java
org.imaginea.botbot.CustomVisitor.java
org.imaginea.botbot.ListenerAdder.java
org.imaginea.botbot.OnClickListenerTest.java
org.imaginea.botbot.OnItemClickListenerTest.java
org.imaginea.botbot.OnItemSelectedListenerTest.java
org.imaginea.botbot.OnTouchListenerTest.java
org.imaginea.botbot.Recorder.java
org.imaginea.botbot.ServerProperties.java
org.imaginea.botbot.TextListner.java
org.imaginea.botbot.ViewClasses.java
org.imaginea.botbot.api.DefaultProperties.java
org.imaginea.botbot.api.IdentifyByType.java
org.imaginea.botbot.api.TestCSVReader.java
org.imaginea.botbot.api.UsefulFunctions.java
org.imaginea.botbot.common.AndroFrameworkExecutorDataDriven.java
org.imaginea.botbot.common.AndroFrameworkExecutor.java
org.imaginea.botbot.common.BaseClass.java
org.imaginea.botbot.common.BotBotTestRunner.java
org.imaginea.botbot.common.CommandExecutor.java
org.imaginea.botbot.common.Command.java
org.imaginea.botbot.common.DataDrivenTestCase.java
org.imaginea.botbot.common.Prefrences.java
org.imaginea.botbot.common.RobotiumBaseClass.java
org.imaginea.botbot.common.TestCaseGenerator.java
org.imaginea.botbot.filereader.BaseReader.java
org.imaginea.botbot.filereader.FileTypeReader.java
org.imaginea.botbot.filereader.PropertiesReader.java
org.imaginea.botbot.keywords.BaseKeywordDefinitions.java
org.imaginea.botbot.keywords.DynamicExecution.java
org.imaginea.botbot.keywords.IKeywords.java
org.imaginea.botbot.keywords.KeywordCaller.java
org.imaginea.botbot.keywords.NativeDriverKeywordDefinitions.java
org.imaginea.botbot.keywords.RobotiumKeywordDefinition.java
org.imaginea.botbot.utility.DataDrivenDataGenerator.java
org.imaginea.botbot.utility.WebViewHandler.java