text:
package org.apache.giraph.yarn;

import static org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.OUTDIR;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;

import com.google.common.collect.Sets;
import java.util.Set;
import org.apache.giraph.conf.GiraphConfiguration;
import org.apache.giraph.conf.GiraphConstants;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.security.Credentials;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.hadoop.yarn.api.records.NodeReport;
import org.apache.hadoop.yarn.api.records.NodeState;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.client.api.YarnClient;
import org.apache.hadoop.yarn.client.api.YarnClientApplication;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.util.Records;

import org.apache.log4j.Logger;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.nio.ByteBuffer;

/**
 * The initial launcher for a YARN-based Giraph job. This class attempts to
 * configure and send a request to the ResourceManager for a single
 * application container to host GiraphApplicationMaster. The RPC connection
 * between the RM and GiraphYarnClient is the YARN ApplicationManager.
 */
public class GiraphYarnClient {
  static {
    Configuration.addDefaultResource("giraph-site.xml");
  }
  /** Class logger */
  private static final Logger LOG = Logger.getLogger(GiraphYarnClient.class);
  /** Sleep time between silent progress checks */
  private static final int JOB_STATUS_INTERVAL_MSECS = 800;
  /** Memory (in MB) to allocate for our ApplicationMaster container */
  private static final int YARN_APP_MASTER_MEMORY_MB = 512;

  /** human-readable job name */
  private final String jobName;
  /** Helper configuration from the job */
  private final GiraphConfiguration giraphConf;
  /** ApplicationId object (needed for RPC to ResourceManager) */
  private ApplicationId appId;
  /** # of sleeps between progress reports to client */
  private int reportCounter;
  /** Yarn client object */
  private YarnClient yarnClient;

  /**
   * Constructor. Requires caller to hand us a GiraphConfiguration.
   *
   * @param giraphConf User-defined configuration
   * @param jobName User-defined job name
   */
  public GiraphYarnClient(GiraphConfiguration giraphConf, String jobName)
    throws IOException {
    this.reportCounter = 0;
    this.jobName = jobName;
    this.appId = null; // can't set this until after start()
    this.giraphConf = giraphConf;
    verifyOutputDirDoesNotExist();
    yarnClient = YarnClient.createYarnClient();
    yarnClient.init(giraphConf);
  }

  /**
   * Submit a request to the Hadoop YARN cluster's ResourceManager
   * to obtain an application container. This will run our ApplicationMaster,
   * which will in turn request app containers for Giraphs' master and all
   * worker tasks.
   * @param verbose Not implemented yet, to provide compatibility w/GiraphJob
   * @return true if job is successful
   */
  public boolean run(final boolean verbose) throws YarnException, IOException {
    // init our connection to YARN ResourceManager RPC
    LOG.info("Running Client");
    yarnClient.start();
    // request an application id from the RM
 // Get a new application id
    YarnClientApplication app = yarnClient.createApplication();
    GetNewApplicationResponse getNewAppResponse = app.
      getNewApplicationResponse();
    checkPerNodeResourcesAvailable(getNewAppResponse);
    // configure our request for an exec container for GiraphApplicationMaster
    ApplicationSubmissionContext appContext = app.
      getApplicationSubmissionContext();
    appId = appContext.getApplicationId();
    //createAppSubmissionContext(appContext);
    appContext.setApplicationId(appId);
    appContext.setApplicationName(jobName);
    LOG.info("Obtained new Application ID: " + appId);
    // sanity check
    applyConfigsForYarnGiraphJob();

    ContainerLaunchContext containerContext = buildContainerLaunchContext();
    appContext.setResource(buildContainerMemory());
    appContext.setAMContainerSpec(containerContext);
    LOG.info("ApplicationSumbissionContext for GiraphApplicationMaster " +
      "launch container is populated.");
    //TODO: priority and queue
    // Set the priority for the application master
    //Priority pri = Records.newRecord(Priority.class);
    // TODO - what is the range for priority? how to decide?
    //pri.setPriority(amPriority);
    //appContext.setPriority(pri);

    // Set the queue to which this application is to be submitted in the RM
    //appContext.setQueue(amQueue);

   // make the request, blow up if fail, loop and report job progress if not
    try {
      LOG.info("Submitting application to ASM");
      // obtain an "updated copy" of the appId for status checks/job kill later
      appId = yarnClient.submitApplication(appContext);
      LOG.info("Got new appId after submission :" + appId);
    } catch (YarnException yre) {
      // TODO
      // Try submitting the same request again
      // app submission failure?
      throw new RuntimeException("submitApplication(appContext) FAILED.", yre);
    }
    LOG.info("GiraphApplicationMaster container request was submitted to " +
      "ResourceManager for job: " + jobName);
    return awaitGiraphJobCompletion();
  }

  /**
   * Without Hadoop MR to check for us, make sure the output dir doesn't exist!
   */
  private void verifyOutputDirDoesNotExist() {
    Path outDir = null;
    try {
      FileSystem fs = FileSystem.get(giraphConf);
      String errorMsg = "__ERROR_NO_OUTPUT_DIR_SET__";
      outDir =
        new Path(fs.getHomeDirectory(), giraphConf.get(OUTDIR, errorMsg));
      FileStatus outStatus = fs.getFileStatus(outDir);
      if (outStatus.isDirectory() || outStatus.isFile() ||
        outStatus.isSymlink()) {
        throw new IllegalStateException("Path " + outDir + " already exists.");
      }
    } catch (IOException ioe) {
      LOG.info("Final output path is: " + outDir);
    }
  }

  /**
   * Configuration settings we need to customize for a Giraph on YARN
   * job. We need to call this EARLY in the job, before the GiraphConfiguration
   * is exported to HDFS for localization in each task container.
   */
  private void applyConfigsForYarnGiraphJob() {
    GiraphConstants.IS_PURE_YARN_JOB.set(giraphConf, true);
    GiraphConstants.SPLIT_MASTER_WORKER.set(giraphConf, true);
    giraphConf.set("mapred.job.id", "giraph_yarn_" + appId); // ZK app base path
  }

  /**
   * Utility to make sure we have the cluster resources we need to run this
   * job. If they are not available, we should die here before too much setup.
   * @param cluster the GetNewApplicationResponse from the YARN RM.
   */
  private void checkPerNodeResourcesAvailable(
    final GetNewApplicationResponse cluster) throws YarnException, IOException {
    // are there enough containers to go around for our Giraph job?
    List<NodeReport> nodes = null;
    long totalAvailable = 0;
    try {
      nodes = yarnClient.getNodeReports(NodeState.RUNNING);
    } catch (YarnException yre) {
      throw new RuntimeException("GiraphYarnClient could not connect with " +
        "the YARN ResourceManager to determine the number of available " +
        "application containers.", yre);
    }
    for (NodeReport node : nodes) {
      LOG.info("Got node report from ASM for" +
        ", nodeId=" + node.getNodeId() +
        ", nodeAddress " + node.getHttpAddress() +
        ", nodeRackName " + node.getRackName() +
        ", nodeNumContainers " + node.getNumContainers());
      totalAvailable += node.getCapability().getMemory();
    }
    // 1 master + all workers in -w command line arg
    final int workers = giraphConf.getMaxWorkers() + 1;
    checkAndAdjustPerTaskHeapSize(cluster);
    final long totalAsk =
      giraphConf.getYarnTaskHeapMb() * workers;
    if (totalAsk > totalAvailable) {
      throw new IllegalStateException("Giraph's estimated cluster heap " +
        totalAsk + "MB ask is greater than the current available cluster " +
        "heap of " + totalAvailable + "MB. Aborting Job.");
    }
  }

  /**
   * Adjust the user-supplied -yh and -w
   * settings if they are too small or large for the current cluster,
   * and re-record the new settings in the GiraphConfiguration for export.
   * @param gnar the GetNewAppResponse from the YARN ResourceManager.
   */
  private void checkAndAdjustPerTaskHeapSize(
    final GetNewApplicationResponse gnar) {
    // do we have the right heap size on these cluster nodes to run our job?
    //TODO:
    //final int minCapacity = gnar.getMinimumResourceCapability().getMemory();
    final int maxCapacity = gnar.getMaximumResourceCapability().getMemory();
    // make sure heap size is OK for this cluster's available containers
    int giraphMem = giraphConf.getYarnTaskHeapMb();
    if (giraphMem == GiraphConstants.GIRAPH_YARN_TASK_HEAP_MB_DEFAULT) {
      LOG.info("Defaulting per-task heap size to " + giraphMem + "MB.");
    }
    if (giraphMem > maxCapacity) {
      LOG.info("Giraph's request of heap MB per-task is more than the " +
        "minimum; downgrading Giraph to" + maxCapacity + "MB.");
      giraphMem = maxCapacity;
    }
    /*if (giraphMem < minCapacity) { //TODO:
      LOG.info("Giraph's request of heap MB per-task is less than the " +
        "minimum; upgrading Giraph to " + minCapacity + "MB.");
      giraphMem = minCapacity;
    }*/
    giraphConf.setYarnTaskHeapMb(giraphMem); // record any changes made
  }

  /**
   * Kill time for the client, report progress occasionally, and otherwise
   * just sleep and wait for the job to finish. If no AM response, kill the app.
   * @return true if job run is successful.
   */
  private boolean awaitGiraphJobCompletion() throws YarnException, IOException {
    boolean done;
    ApplicationReport report = null;
    try {
      do {
        try {
          Thread.sleep(JOB_STATUS_INTERVAL_MSECS);
        } catch (InterruptedException ir) {
          LOG.info("Progress reporter's sleep was interrupted!", ir);
        }
        report = yarnClient.getApplicationReport(appId);
        done = checkProgress(report);
      } while (!done);
      if (!giraphConf.metricsEnabled()) {
        cleanupJarCache();
      }
    } catch (IOException ex) {
      final String diagnostics = (null == report) ? "" :
        "Diagnostics: " + report.getDiagnostics();
      LOG.error("Fatal fault encountered, failing " + jobName + ". " +
        diagnostics, ex);
      try {
        LOG.error("FORCIBLY KILLING Application from AppMaster.");
        yarnClient.killApplication(appId);
      } catch (YarnException yre) {
        LOG.error("Exception raised in attempt to kill application.", yre);
      }
      return false;
    }
    return printFinalJobReport();
  }

  /**
   * Deletes the HDFS cache in YARN, which replaces DistributedCache of Hadoop.
   * If metrics are enabled this will not get called (so you can examine cache.)
   * @throws IOException if bad things happen.
   */
  private void cleanupJarCache() throws IOException {
    FileSystem fs = FileSystem.get(giraphConf);
    Path baseCacheDir = YarnUtils.getFsCachePath(fs, appId);
    if (fs.exists(baseCacheDir)) {
      LOG.info("Cleaning up HDFS distributed cache directory for Giraph job.");
      fs.delete(baseCacheDir, true); // stuff inside
      fs.delete(baseCacheDir, false); // dir itself
    }
  }

  /**
   * Print final formatted job report for local client that initiated this run.
   * @return true for app success, false for failure.
   */
  private boolean printFinalJobReport() throws YarnException, IOException {
    ApplicationReport report;
    try {
      report = yarnClient.getApplicationReport(appId);
      FinalApplicationStatus finalAppStatus =
        report.getFinalApplicationStatus();
      final long secs =
        (report.getFinishTime() - report.getStartTime()) / 1000L;
      final String time = String.format("%d minutes, %d seconds.",
        secs / 60L, secs % 60L);
      LOG.info("Completed " + jobName + ": " +
        finalAppStatus.name() + ", total running time: " + time);
    } catch (YarnException yre) {
      LOG.error("Exception encountered while attempting to request " +
        "a final job report for " + jobName , yre);
      return false;
    }
    return true;
  }

  /**
   * Compose the ContainerLaunchContext for the Application Master.
   * @return the CLC object populated and configured.
   */
  private ContainerLaunchContext buildContainerLaunchContext()
    throws IOException {
    ContainerLaunchContext appMasterContainer =
      Records.newRecord(ContainerLaunchContext.class);
    appMasterContainer.setEnvironment(buildEnvironment());
    appMasterContainer.setLocalResources(buildLocalResourceMap());
    appMasterContainer.setCommands(buildAppMasterExecCommand());
    //appMasterContainer.setResource(buildContainerMemory());
    //appMasterContainer.setUser(ApplicationConstants.Environment.USER.name());
    setToken(appMasterContainer);
    return appMasterContainer;
  }

  /**
   * Set delegation tokens for AM container
   * @param amContainer AM container
   * @return
   */
  private void setToken(ContainerLaunchContext amContainer) throws IOException {
    // Setup security tokens
    if (UserGroupInformation.isSecurityEnabled()) {
      Credentials credentials = new Credentials();
      String tokenRenewer = giraphConf.get(YarnConfiguration.RM_PRINCIPAL);
      if (tokenRenewer == null || tokenRenewer.length() == 0) {
        throw new IOException(
          "Can't get Master Kerberos principal for the RM to use as renewer");
      }
      FileSystem fs = FileSystem.get(giraphConf);
      // For now, only getting tokens for the default file-system.
      final Token<?> [] tokens =
        fs.addDelegationTokens(tokenRenewer, credentials);
      if (tokens != null) {
        for (Token<?> token : tokens) {
          LOG.info("Got dt for " + fs.getUri() + "; " + token);
        }
      }
      DataOutputBuffer dob = new DataOutputBuffer();
      credentials.writeTokenStorageToStream(dob);
      ByteBuffer fsTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
      amContainer.setTokens(fsTokens);
    }
  }

  /**
   * Assess whether job is already finished/failed and 'done' flag needs to be
   * set, prints progress display for client if all is going well.
   * @param report the application report to assess.
   * @return true if job report indicates the job run is over.
   */
  private boolean checkProgress(final ApplicationReport report) {
    YarnApplicationState jobState = report.getYarnApplicationState();
    if (jobState == YarnApplicationState.FINISHED ||
      jobState == YarnApplicationState.KILLED) {
      return true;
    } else if (jobState == YarnApplicationState.FAILED) {
      LOG.error(jobName + " reports FAILED state, diagnostics show: " +
        report.getDiagnostics());
      return true;
    } else {
      if (reportCounter++ % 5 == 0) {
        displayJobReport(report);
      }
    }
    return false;
  }

  /**
   * Display a formatted summary of the job progress report from the AM.
   * @param report the report to display.
   */
  private void displayJobReport(final ApplicationReport report) {
    if (null == report) {
      throw new IllegalStateException("[*] Latest ApplicationReport for job " +
        jobName + " was not received by the local client.");
    }
    final float elapsed =
      (System.currentTimeMillis() - report.getStartTime()) / 1000.0f;
    LOG.info(jobName + ", Elapsed: " + String.format("%.2f secs", elapsed));
    LOG.info(report.getCurrentApplicationAttemptId() + ", State: " +
      report.getYarnApplicationState().name() + ", Containers used: " +
      report.getApplicationResourceUsageReport().getNumUsedContainers());
  }

  /**
   * Utility to produce the command line to activate the AM from the shell.
   * @return A List<String> of shell commands to execute in
   *         the container allocated to us by the RM to host our App Master.
   */
  private List<String> buildAppMasterExecCommand() {
    // 'gam-' prefix is for GiraphApplicationMaster in log file names
    return ImmutableList.of("${JAVA_HOME}/bin/java " +
      "-Xmx" + YARN_APP_MASTER_MEMORY_MB + "M " +
      "-Xms" + YARN_APP_MASTER_MEMORY_MB + "M " + // TODO: REMOVE examples jar!
      //TODO: Make constant
      "-cp .:${CLASSPATH} org.apache.giraph.yarn.GiraphApplicationMaster " +
      "1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/gam-stdout.log " +
      "2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/gam-stderr.log "
    );
  }

  /**
   * Check if the job's configuration is for a local run. These can all be
   * removed as we expand the functionality of the "pure YARN" Giraph profile.
   */
  private void checkJobLocalZooKeeperSupported() {
    final boolean isZkExternal = giraphConf.isZookeeperExternal();
    final String checkZkList = giraphConf.getZookeeperList();
    if (!isZkExternal || checkZkList.isEmpty()) {
      throw new IllegalArgumentException("Giraph on YARN does not currently" +
          "support Giraph-managed ZK instances: use a standalone ZooKeeper.");
    }
  }

  /**
   * Register all local jar files from GiraphConstants.GIRAPH_YARN_LIBJARS
   * in the LocalResources map, copy to HDFS on that same registered path.
   * @param map the LocalResources list to populate.
   */
  private void addLocalJarsToResourceMap(Map<String, LocalResource> map)
    throws IOException {
    Set<String> jars = Sets.newHashSet();
    LOG.info("LIB JARS :" + giraphConf.getYarnLibJars());
    String[] libJars = giraphConf.getYarnLibJars().split(",");
    for (String libJar : libJars) {
      jars.add(libJar);
    }
    FileSystem fs = FileSystem.get(giraphConf);
    Path baseDir = YarnUtils.getFsCachePath(fs, appId);
    for (Path jar : YarnUtils.getLocalFiles(jars)) {
      Path dest = new Path(baseDir, jar.getName());
      LOG.info("Made local resource for :" + jar + " to " +  dest);
      fs.copyFromLocalFile(false, true, jar, dest);
      YarnUtils.addFileToResourceMap(map, fs, dest);
    }
  }

  /**
   * Construct the memory requirements for the AppMaster's container request.
   * @return A Resource that wraps the memory request.
   */
  private Resource buildContainerMemory() {
    Resource capability = Records.newRecord(Resource.class);
    capability.setMemory(YARN_APP_MASTER_MEMORY_MB); //Configurable thru CLI?
    return capability;
  }

  /**
   * Create the mapping of environment vars that will be visible to the
   * ApplicationMaster in its remote app container.
   * @return a map of environment vars to set up for the AppMaster.
   */
  private Map<String, String> buildEnvironment() {
    Map<String, String> environment =
      Maps.<String, String>newHashMap();
    LOG.info("Set the environment for the application master");
    YarnUtils.addLocalClasspathToEnv(environment, giraphConf);
    //TODO: add the runtime classpath needed for tests to work
    LOG.info("Environment for AM :" + environment);
    return environment;
  }

  /**
   * Create the mapping of files and JARs to send to the GiraphApplicationMaster
   * and from there on to the Giraph tasks.
   * @return the map of jars to local resource paths for transport
   *   to the host container that will run our AppMaster.
   */
  private Map<String, LocalResource> buildLocalResourceMap() {
    // set local resources for the application master
    // local files or archives as needed
    // In this scenario, the jar file for the application master
    //is part of the local resources
    Map<String, LocalResource> localResources =
        Maps.<String, LocalResource>newHashMap();
    LOG.info("buildLocalResourceMap ....");
    try {
      // export the GiraphConfiguration to HDFS for localization to remote tasks
      //Ques: Merge the following two method
      YarnUtils.exportGiraphConfiguration(giraphConf, appId);
      YarnUtils.addGiraphConfToLocalResourceMap(
        giraphConf, appId, localResources);
      // add jars from '-yj' cmd-line arg to resource map for localization
      addLocalJarsToResourceMap(localResources);
      //TODO: log4j?
      return localResources;
    } catch (IOException ioe) {
      throw new IllegalStateException("Failed to build LocalResouce map.", ioe);
    }
  }

}


text:
package com.xinyou.label.domain.viewes;

import java.math.BigDecimal;

public class CTN_MAIN_VIEW {
	private String ctn_main_guid;
	private String ctn_main_id;
	private String ctn_name;
	private int ctn_type;
    private String ctn_baco;
    private int ctn_status;

    private int parent_ctn_type;
    private String parent_ctn_guid;
	private String parent_ctn_id;
    private String parent_ctn_baco;

	private String itm_id;
    private String itm_name;
    private String itm_spec;
    private String itm_unit;
    private BigDecimal itm_qty;
    private BigDecimal itm_got_qty;

    private String wh_guid;
	private String wh_id;
    private String wh_name;
    private String wh_baco;
    private String wh_area_guid;
    private String wh_area_id;
    private String wh_area_baco;
    private String wh_shelf_guid;
    private String wh_shelf_id;
    private String wh_shelf_baco;
    private String wh_loc_guid;
    private String wh_loc_id;
    private String wh_loc_baco;
    private String wh_plt_guid;
    private String wh_plt_id;
    private String wh_plt_baco;
    private String wh_package_guid;
    private String wh_package_id;
    private String wh_package_baco;

    private int base_type;
    private String base_id;
    private String base_seqno;;
    private String lot_id;
    private String def_loc_id;

    private String stk_guid;
    private String updated_by;
    private String created_by;

    public String getCreated_by() {
		return created_by;
	}
	public void setCreated_by(String created_by) {
		this.created_by = created_by;
	}
	public String getUpdated_by() {
		return updated_by;
	}
	public void setUpdated_by(String updated_by) {
		this.updated_by = updated_by;
	}
	public String getStk_guid() {
		return stk_guid;
	}
	public void setStk_guid(String stk_guid) {
		this.stk_guid = stk_guid;
	}
	public String getDef_loc_id() {
		return def_loc_id;
	}
	public void setDef_loc_id(String def_loc_id) {
		this.def_loc_id = def_loc_id;
	}
	public int getBase_type() {
		return base_type;
	}
	public void setBase_type(int base_type) {
		this.base_type = base_type;
	}
	public String getBase_id() {
		return base_id;
	}
	public void setBase_id(String base_id) {
		this.base_id = base_id;
	}
	public String getBase_seqno() {
		return base_seqno;
	}
	public void setBase_seqno(String base_seqno) {
		this.base_seqno = base_seqno;
	}
    public String getLot_id() {
		return lot_id;
	}
	public void setLot_id(String lot_id) {
		this.lot_id = lot_id;
	}
	public String getParent_ctn_guid() {
		return parent_ctn_guid;
	}
	public void setParent_ctn_guid(String parent_ctn_guid) {
		this.parent_ctn_guid = parent_ctn_guid;
	}
    public String getWh_guid() {
		return wh_guid;
	}
	public void setWh_guid(String wh_guid) {
		this.wh_guid = wh_guid;
	}
	public String getWh_area_guid() {
		return wh_area_guid;
	}
	public void setWh_area_guid(String wh_area_guid) {
		this.wh_area_guid = wh_area_guid;
	}
	public String getWh_shelf_guid() {
		return wh_shelf_guid;
	}
	public void setWh_shelf_guid(String wh_shelf_guid) {
		this.wh_shelf_guid = wh_shelf_guid;
	}
	public String getWh_loc_guid() {
		return wh_loc_guid;
	}
	public void setWh_loc_guid(String wh_loc_guid) {
		this.wh_loc_guid = wh_loc_guid;
	}
	public String getWh_plt_guid() {
		return wh_plt_guid;
	}
	public void setWh_plt_guid(String wh_plt_guid) {
		this.wh_plt_guid = wh_plt_guid;
	}
	public String getWh_package_guid() {
		return wh_package_guid;
	}
	public void setWh_package_guid(String wh_package_guid) {
		this.wh_package_guid = wh_package_guid;
	}
	public String getCtn_main_guid() {
		return ctn_main_guid;
	}
	public void setCtn_main_guid(String ctn_main_guid) {
		this.ctn_main_guid = ctn_main_guid;
	}
	public String getCtn_main_id() {
		return ctn_main_id;
	}
	public void setCtn_main_id(String ctn_main_id) {
		this.ctn_main_id = ctn_main_id;
	}
	public String getCtn_name() {
		return ctn_name;
	}
	public void setCtn_name(String ctn_name) {
		this.ctn_name = ctn_name;
	}
	public int getCtn_type() {
		return ctn_type;
	}
	public void setCtn_type(int ctn_type) {
		this.ctn_type = ctn_type;
	}
	public String getCtn_baco() {
		return ctn_baco;
	}
	public void setCtn_baco(String ctn_baco) {
		this.ctn_baco = ctn_baco;
	}
	public int getCtn_status() {
		return ctn_status;
	}
	public void setCtn_status(int ctn_status) {
		this.ctn_status = ctn_status;
	}
	public int getParent_ctn_type() {
		return parent_ctn_type;
	}
	public void setParent_ctn_type(int parent_ctn_type) {
		this.parent_ctn_type = parent_ctn_type;
	}
	public String getParent_ctn_id() {
		return parent_ctn_id;
	}
	public void setParent_ctn_id(String parent_ctn_id) {
		this.parent_ctn_id = parent_ctn_id;
	}
	public String getParent_ctn_baco() {
		return parent_ctn_baco;
	}
	public void setParent_ctn_baco(String parent_ctn_baco) {
		this.parent_ctn_baco = parent_ctn_baco;
	}
    public String getItm_id() {
		return itm_id;
	}
	public void setItm_id(String itm_id) {
		this.itm_id = itm_id;
	}
	public String getItm_name() {
		return itm_name;
	}
	public void setItm_name(String itm_name) {
		this.itm_name = itm_name;
	}
	public String getItm_spec() {
		return itm_spec;
	}
	public void setItm_spec(String itm_spec) {
		this.itm_spec = itm_spec;
	}
	public String getItm_unit() {
		return itm_unit;
	}
	public void setItm_unit(String itm_unit) {
		this.itm_unit = itm_unit;
	}
	public BigDecimal getItm_qty() {
		return itm_qty;
	}
	public void setItm_qty(BigDecimal itm_qty) {
		this.itm_qty = itm_qty;
	}
	public BigDecimal getItm_got_qty() {
		return itm_got_qty;
	}
	public void setItm_got_qty(BigDecimal itm_got_qty) {
		this.itm_got_qty = itm_got_qty;
	}
	public String getWh_id() {
		return wh_id;
	}
	public void setWh_id(String wh_id) {
		this.wh_id = wh_id;
	}
	public String getWh_name() {
		return wh_name;
	}
	public void setWh_name(String wh_name) {
		this.wh_name = wh_name;
	}
	public String getWh_baco() {
		return wh_baco;
	}
	public void setWh_baco(String wh_baco) {
		this.wh_baco = wh_baco;
	}
	public String getWh_area_id() {
		return wh_area_id;
	}
	public void setWh_area_id(String wh_area_id) {
		this.wh_area_id = wh_area_id;
	}
	public String getWh_area_baco() {
		return wh_area_baco;
	}
	public void setWh_area_baco(String wh_area_baco) {
		this.wh_area_baco = wh_area_baco;
	}
	public String getWh_shelf_id() {
		return wh_shelf_id;
	}
	public void setWh_shelf_id(String wh_shelf_id) {
		this.wh_shelf_id = wh_shelf_id;
	}
	public String getWh_shelf_baco() {
		return wh_shelf_baco;
	}
	public void setWh_shelf_baco(String wh_shelf_baco) {
		this.wh_shelf_baco = wh_shelf_baco;
	}
	public String getWh_loc_id() {
		return wh_loc_id;
	}
	public void setWh_loc_id(String wh_loc_id) {
		this.wh_loc_id = wh_loc_id;
	}
	public String getWh_loc_baco() {
		return wh_loc_baco;
	}
	public void setWh_loc_baco(String wh_loc_baco) {
		this.wh_loc_baco = wh_loc_baco;
	}
	public String getWh_plt_id() {
		return wh_plt_id;
	}
	public void setWh_plt_id(String wh_plt_id) {
		this.wh_plt_id = wh_plt_id;
	}
	public String getWh_plt_baco() {
		return wh_plt_baco;
	}
	public void setWh_plt_baco(String wh_plt_baco) {
		this.wh_plt_baco = wh_plt_baco;
	}
	public String getWh_package_id() {
		return wh_package_id;
	}
	public void setWh_package_id(String wh_package_id) {
		this.wh_package_id = wh_package_id;
	}
	public String getWh_package_baco() {
		return wh_package_baco;
	}
	public void setWh_package_baco(String wh_package_baco) {
		this.wh_package_baco = wh_package_baco;
	}
//	public String getOrder_no() {
//		return order_no;
//	}
//	public void setOrder_no(String order_no) {
//		this.order_no = order_no;
//	}
//	public String getBill_no() {
//		return bill_no;
//	}
//	public void setBill_no(String bill_no) {
//		this.bill_no = bill_no;
//	}
//	public String getWork_no() {
//		return work_no;
//	}
//	public void setWork_no(String work_no) {
//		this.work_no = work_no;
//	}
//	public String getRouting_no() {
//		return routing_no;
//	}
//	public void setRouting_no(String routing_no) {
//		this.routing_no = routing_no;
//	}

	public boolean isEmpty()
	{
		if(this.ctn_main_guid==null||this.ctn_main_guid.trim().length()==0) return true;
		return false;
	}
}

redpajama_set_name: RedPajamaGithub


text:
export interface ISAMLGlobalSettings {
	generateUsername: boolean;
	nameOverwrite: boolean;
	mailOverwrite: boolean;
	immutableProperty: string;
	defaultUserRole: string;
	roleAttributeName: string;
	roleAttributeSync: boolean;
	userDataFieldMap: string;
	usernameNormalize: string;
}


text:
package com.stratio.cassandra.lucene

import com.stratio.cassandra.lucene.IndexException._
import org.slf4j.helpers.MessageFormatter

/** [[RuntimeException]] to be thrown when there are Lucene index-related errors.
  *
  * @param message the detail message
  * @param cause   the cause
  * @author Andres de la Pena `adelapena@stratio.com`
  */
case class IndexException(
    message: String,
    cause: Throwable)
  extends RuntimeException(message, cause) {

  /** Constructs a new index exception with the specified cause.
    *
    * @param cause the cause
    */
  def this(cause: Throwable) = this(null, cause)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param message the detail message
    */
  def this(message: String) =
  this(message, null)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param message the detail message
    * @param a1      first argument
    */
  def this(message: String, a1: AnyRef) =
  this(format1(message, a1), null)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param message the detail message
    * @param a1      first argument
    * @param a2      second argument
    */
  def this(message: String, a1: AnyRef, a2: AnyRef) =
  this(format2(message, a1, a2), null)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param message the detail message
    * @param a1      first argument
    * @param a2      second argument
    * @param a3      third argument
    */
  def this(message: String, a1: AnyRef, a2: AnyRef, a3: AnyRef) =
  this(formatN(message, a1, a2, a3), null)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param message the detail message
    * @param a1      first argument
    * @param a2      second argument
    * @param a3      third argument
    * @param a4      fourth argument
    */
  def this(message: String, a1: AnyRef, a2: AnyRef, a3: AnyRef, a4: AnyRef) =
  this(formatN(message, a1, a2, a3, a4), null)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param cause   the cause
    * @param message the detail message
    */
  def this(cause: Throwable, message: String) =
  this(message, cause)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param cause   the cause
    * @param message the detail message
    * @param a1      first argument
    */
  def this(cause: Throwable, message: String, a1: AnyRef) =
  this(format1(message, a1), cause)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param cause   the cause
    * @param message the detail message
    * @param a1      first argument
    * @param a2      second argument
    */
  def this(cause: Throwable, message: String, a1: AnyRef, a2: AnyRef) =
  this(format2(message, a1, a2), cause)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param cause   the cause
    * @param message the detail message
    * @param a1      first argument
    * @param a2      second argument
    * @param a3      third argument
    */
  def this(cause: Throwable, message: String, a1: AnyRef, a2: AnyRef, a3: AnyRef) =
  this(formatN(message, a1, a2, a3), cause)

  /** Constructs a new index exception with the specified formatted detail message.
    *
    * @param cause   the cause
    * @param message the detail message
    * @param a1      first argument
    * @param a2      second argument
    * @param a3      third argument
    * @param a4      fourth argument
    */
  def this(cause: Throwable, message: String, a1: AnyRef, a2: AnyRef, a3: AnyRef, a4: AnyRef) =
  this(formatN(message, a1, a2, a3, a4), cause)

}

/** Companion object for [[IndexException]]. */
object IndexException {

  private def format1(message: String, arg: AnyRef): String = {
    MessageFormatter.format(message, arg).getMessage
  }

  private def format2(message: String, a1: AnyRef, a2: AnyRef): String = {
    MessageFormatter.format(message, a1, a2).getMessage
  }

  private def formatN(message: String, as: AnyRef*): String = {
    MessageFormatter.arrayFormat(message, as.toArray).getMessage
  }

}


text:
package com.android.nitecafe.whirlpoolnews.utilities.interfaces;

import com.android.nitecafe.whirlpoolnews.models.ScrapedPostList;
import com.android.nitecafe.whirlpoolnews.models.ScrapedThread;
import com.android.nitecafe.whirlpoolnews.models.ScrapedThreadList;

import java.util.ArrayList;
import java.util.List;

import rx.Observable;

public interface IThreadScraper {
    Observable<ScrapedThreadList> scrapeThreadsFromForumObservable(int forum_id, int page_number, int group_id);

    Observable<ScrapedPostList> scrapePostsFromThreadObservable(int threadId, int page);

    Observable<ArrayList<ScrapedThread>> ScrapPopularThreadsObservable();

    Observable<List<ScrapedThread>> searchThreadsObservable(int forum_id, int group_id, String query);
}


text:
"""
Usage:
  rabbit.py imgetter <url> [<savedir>]
  rabbit.py splitfile <file_or_dir> [<size>]
  rabbit.py test
  rabbit.py urljoin <baseurl> [<url>]

Arguments:
  url           url
  savedir       dirpath
  size          int, ex:1 for 1M

Options:
  -h --help     show this help
"""
# todo: url2ip() to convert url to ip

import csv
import carrot
import datetime
import glob
import os
import re
import sys
import time
from decimal import Decimal
from docopt import docopt  # pip
from collections import defaultdict
# from hashlib import md5

reload(sys)
sys.setdefaultencoding('utf8')
BASE_DIR = os.path.split(os.path.realpath(__file__))[0]

# tree
tree = lambda: defaultdict(tree)

def filesplitter(*args, **kwargs):
    """
    split txtfile and return filenames
    @size=10: split file by 10M, default 10
    """
    input_filenames = []
    for arg in args:
        if os.path.isfile(arg):
            input_filenames.append(arg)
        elif os.path.isdir(arg):
            for parent, firnames, filenames in os.walk(arg):
                for filename in filenames:
                    input_filenames.append(os.path.
                                           join(os.path.
                                                abspath(parent),
                                                filename))
    try:
        size = kwargs.get('size')
        size = int(size) if size else 10
    except ValueError as e:
        raise ValueError('Invalid params: %s' % str(kwargs))
    _tmp_dir = filer(None, os.path.join(carrot.TMPDIR, 'data'))

    def _filewriter(filename, block):
        with open(sub_filename, 'w') as sub_f:
            sub_f.writelines(block)
        return True

    output_filenames = []
    for filename in input_filenames:
        sub_count = 0
        f = open(filename)
        while True:
            block = f.readlines(1024000 * size)  # 1M
            if not block:
                break
            sub_filename = os.path.join(_tmp_dir,  # tmp data dir
                                        ('-%s' % sub_count).  # subcount
                                        join(os.path.splitext(os.  # filename
                                        path.split(filename)[-1])))
            if _filewriter(filename, block):
                output_filenames.append(sub_filename)
            sub_count += 1
    return output_filenames

def xurljoin(base, url):
    """
    xurljoin(base, url)
    improved func for uelpsrse.urljoin
    article from: http://www.coder4.com/archives/2674
    @base   baseurl
    @url    path
    """
    from urlparse import urljoin
    from urlparse import urlparse
    from urlparse import urlunparse
    from purl import URL

    url = url if url else ''
    url1 = urljoin(base, url)
    arr = urlparse(url1)
    path = URL(arr[2]).path()
    return urlunparse((arr.scheme, arr.netloc, path,
                       arr.params, arr.query, arr.fragment))

def imgetter(url, savedir=''):
    """
    download img from url, save to savedir
    @savedir path to save img

    usage:
    >>> url = 'http://www.itprofessor.cn/media/media.jpg'
    >>> imgetter(url)
    """
    from cStringIO import StringIO
    import purl  # pip
    import requests  # pip
    from PIL import Image  # pip
    url = url.strip()
    url_resp = requests.get(url)
    img = Image.open(StringIO(url_resp.content)) if url_resp.ok else None
    if isinstance(img, Image.Image):
        parse = purl.URL(url)
        imgname = os.path.splitext(parse.path().strip('/').
                                   replace('/', '_'))[0]
        savedir = savedir if savedir else ''
        img.save(filer('%s.%s' % (imgname, img.format.lower()),
                 savedir))
        return True
    else:
        raise TypeError('not a image url: %s' % url)

class PoolManager(object):
    from multiprocessing import cpu_count
    from multiprocessing import Pool

    def __init__(self, args):
        """
        PoolManager(args)

        usage:
        >>> jobs = [(func1, args1), (func2, args2)]
        >>> p = PoolManager(jobs)
        >>> p.run()
        """
        self.pool = Pool(cpu_count())
        self.args = [i for i in args]

    def add(self, args):
        self.args += [i for i in args]

    def run(self):
        self.collector = []
        jobs_num = len(self.args)
        bar_length = 30
        for index, (func, argv) in enumerate(self.args):
            if jobs_num > 1:
                percent = index / float(jobs_num - 1) * 100
                hashes = '#' * int(percent / 100.0 * bar_length)
                spaces = ' ' * (bar_length - len(hashes))
                sys.stdout.write("\r%s: [%s] %d%%" % ('Add',
                                                      hashes + spaces,
                                                      percent))
                sys.stdout.flush()
            result = self.pool.apply_async(func, argv)
            # result = self.pool.apply_async(func, (argv, ))
            self.collector.append([func.__name__, argv, result])
        self.pool.close()
        self.pool.join()

        # num of jobs in pool
        jobs_successful = 0
        while jobs_successful < jobs_num:
            for index, job in enumerate(self.collector):
                if jobs_num > 1:
                    percent = index / float(jobs_num - 1) * 100
                    hashes = '#' * int(percent / 100.0 * bar_length)
                    spaces = ' ' * (bar_length - len(hashes))
                    sys.stdout.write("\r%s: [%s] %d%%" % ('Run',
                                                          hashes + spaces,
                                                          percent))
                    sys.stdout.flush()

                result = job[-1]
                if not isinstance(result, list) and result.successful():
                    del self.collector[index][-1]
                    self.collector[index].append(result.get())
                    jobs_successful += 1
        sys.stdout.write('\n')
        sys.stdout.flush()
        return self.collector

def filer(filename='', filedir='./'):
    """
    filer(filename='', filedir='./')
    return fullpath
    auto create filedir
    if filename is null, only filedir be created
    """
    filedir = os.path.abspath(filedir)
    os.makedirs(filedir) if not os.path.isdir(filedir) else None
    return (os.path.join(filedir, filename) if filename else filedir)

def logger(name, logname, logdir='./'):
    """
    logger(name, logname, logdir='./')
    high level logging

    how to use:
    alog = logger('default', 'log13.txt')
    alog.debug('debug message!')
    alog.info('info message!')
    alog.error('error message')
    alog.critical('critical message')
    alog.warning('warning message')
    """
    import logging
    import logging.config
    logging.config.dictConfig({
        'version': 1,
        'disable_existing_loggers': True,
        'formatters': {
            'default': {'format': '%(asctime)s %(levelname)s %(message)s',
                        'datefmt': '%Y-%m-%d %H:%M:%S',
                        },
            'verbose': {'format': '%(asctime)s %(levelname)s %(module)s \
                %(process)d %(thread)d %(message)s',
                        'datefmt': '%Y-%m-%d %H:%M:%S',
                        },
            'simple': {'format': '%(levelname)s %(message)s',
                       'datefmt': '%Y-%m-%d %H:%M:%S'
                       },
        },
        'handlers': {
            'console': {
                'level': 'DEBUG',
                'class': 'logging.StreamHandler',
                'formatter': 'default',
                'stream': 'ext://sys.stdout',
            },
            'file': {
                'level': 'INFO',
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'default',
                'filename': filer(logname, logdir),
                'maxBytes': 1024000,
                'backupCount': 3,
                'encoding': 'utf8',
            },
        },
        'loggers': {
            'default': {
                'level': 'DEBUG',
                'handlers': ['console', 'file'],
            },
            'file': {
                'level': 'INFO',
                'handlers': ['file'],
            }
        },
        # 'disable_existing_loggers': False,
    })
    return logging.getLogger(name)

def func_monitor(trace_this=True):
    """
    func_monitor(trace_this=True)
    A decorator to show running time of a func
    @trace_this: print running_time or not

    eg:
    @func_monitor(trace_this=True)
    def func...
    """
    from functools import wraps
    if trace_this:
        def _time_decorator(func):
            @wraps(func)
            def _wrapper(*args, **kwargs):
                _start_time = datetime.datetime.now()
                _resp = func(*args, **kwargs)
                _end_time = datetime.datetime.now()
                _time_diff = (_end_time - _start_time).total_seconds()
                print (u"<%s> used %s s." % (func.__name__, _time_diff))
                return _resp
            return _wrapper
    else:
        @wraps(func)
        def _time_decorator(func):
            return func
    return _time_decorator

def time_builder(basetime='', timedelta=0, target_type='day'):
    """
    time_builder(basetime='', timedelta=0, target_type='day')
    Generate time with target_type
    @basetime: input a time or None by default
    @timedelta: basetime + timedelta = target_time
    @target_type: day, month, year, month_start

    # doctest
    >>> time_builder(basetime='20160310')
    '2016-03-10'
    >>> time_builder(basetime='20160310', target_type='month_start')
    '2016-03-01'
    >>> time_builder(basetime='20160310', target_type='year')
    '2016'
    >>> time_builder(basetime='20160310', timedelta=-1, target_type='day')
    '2016-03-09'
    >>> time_builder(basetime='20160310', timedelta=30, target_type='month')
    '2016-04'
    """
    if basetime:
        basetime = unicode(basetime).replace("-", "")
        try:
            basetime = time.strptime(basetime, '%Y%m%d')
            basetime = datetime.datetime(*basetime[:3])
        except:
            raise ValueError(r'basetime should be None or an exsit day')
            # return False
    else:
        basetime = datetime.datetime.now()

    _oneday = datetime.timedelta(days=1)
    _target_type_dict = {
        'year': '%Y',
        'month': '%Y-%m',
        'month_start': '%Y-%m-01',
        'day': '%Y-%m-%d',
        'hour': '%Y-%m-%d %H:00:00',
        'minute': '%Y-%m-%d %H:%M:00',
        'second': '%Y-%m-%d %H:%M:%S',
        'dbYHMS/': '%d/%b/%Y:%H:%M:%S',
        'dbY/': '%d/%b/%Y',  # '27/Mar/2016'
        'dbY-': '%d-%b-%Y',  # '27-Mar-2016'
        'mdYHMS/': '%m/%d/%Y:%H:%M:%S',
        'mdY000/': '%m/%d/%Y:00:00:00',
        'full_time': "%a, %d %b %Y %H:%M:%S %z",
    }
    _target_time = basetime + _oneday * timedelta
    try:
        return datetime.datetime.strftime(_target_time,
                                          _target_type_dict[target_type])
    except KeyError as e:
        raise KeyError("`target_type` must in %s" % _target_type_dict.keys())

def lister(*args, **kwargs):
    """
    lister(*args, **kwargs)
    Convert int, tuple, etc to list with target type if it can be
    @kwargs['target_type']<var_type>: int, str(unicode), unicode,
                                      float, Deciaml

    # doctest
    >>> lister(1, 2, 3)
    [1, 2, 3]
    >>> lister(1, 2, 3, target_type=float)
    [1.0, 2.0, 3.0]
    >>> lister(1, 2, 3, target_type=str)
    [u'1', u'2', u'3']
    >>> lister('a', 'b', '3', target_type=int)
    ['a', 'b', 3]
    >>> lister(1, 2, (3, 4), [[[5], 6], 7], )
    [1, 2, 3, 4, 5, 6, 7]
    """
    target_type = kwargs['target_type'] if kwargs else None
    target_type = unicode if target_type in (str,) else target_type
    _collector = []

    def _iterator(items, target_type):
        for item in items:
            if isinstance(item, (list, tuple, set,)):
                _iterator(item, target_type)
            else:
                try:
                    _collector.append(target_type(item))
                except (ValueError, TypeError) as e:
                    _collector.append(item)
    _iterator(args, target_type)
    return _collector

def distinct(*args):
    """
    distinct(*args)
    return distinct items
    same func as set
    """
    items = lister(args)
    func = lambda x, y: x if y in x else x + [y]
    return reduce(func, [[], ] + items)

def xls2dict(filename):
    """
    xls2dict(filename)
    get a xls or xlsx, return a list
    """
    import xlrd  # pip

    collector = []
    _full_filename = os.path.abspath(filename)
    try:
        data = xlrd.open_workbook(_full_filename)
    except:
        raise ValueError('%s is not a xls_type file' % filename)

    for table in data.sheets():
        table_collector = []
        nrows = table.nrows
        ncols = table.ncols
        if not (nrows and ncols):
            continue
        for row in range(nrows):
            table_collector.append(table.row_values(row))
        table_info = {
            'name': table.name,
            'data': table_collector,
            'rows': nrows,
            'cols': ncols,
            'title': table.row_values(0)
        }
        collector.append(table_info)
    return collector

def csv2xls(filename):
    """
    csv2xls(filename)
    given a csv file, convert to xls and save at the same dir
    warning: maxline_of_csvfile <=65535
    """
    _full_filename = os.path.abspath(filename)
    try:
        _csv_reader = csv.reader(open(_full_filename))
    except:
        raise ValueError('%s is not a csv_type file' % filename)
    _xls_name = re.sub('\..*$', '.xls', _full_filename, 1)
    _xlsapp = XlsManager(_xls_name)
    for row in _csv_reader:
        _xlsapp.writerow(row)

    _xlsapp.close()
    return True

class CsvManager(object):
    def __init__(self, filename, mode='wb', filedir='./', **kwargs):
        """
        CsvManager(filename, mode='wb', filedir='./')
        <class>: wrapper csv model, adapt to Chinese
        @filename<str>: file name
        @mode<str>: open_mode
        @filedir<str>: filedir to save file
        todo: addtitle
        """
        self.title = kwargs.get('title', None)

        # makedirs if not exsit
        filedir = os.path.abspath(filedir)
        os.makedirs(filedir) if not os.path.isdir(filedir) else True
        # create csv file
        filename = unicode(filename)
        filename += '.csv' if not filename.endswith('.csv') else ''
        self._full_filename = os.path.join(filedir, filename)
        _write_bom = False if os.path.isfile(self._full_filename) else True
        try:
            self._file = open(self._full_filename, mode)
        except IOError as e:
            raise IOError("Permission denied: close file %s and try again" % self._full_filename)

        # adapt to Chinese
        if _write_bom or mode.startswith('w'):
            self._file.write('\xEF\xBB\xBF')

        self._writer = csv.writer(self._file)

    def writerow(self, *args):
        items = lister(args)
        if items:
            self._writer.writerow(items)

    def close(self):
        """
        use it when you want to close it manually
        """
        if not self._file.closed:
            self._file.close()

    def csv2xls(self, delete_csv=False):
        """
        convert csv file to xls file
        must be used after csv file closed
        """
        self.close()
        resp = csv2xls(self._full_filename)
        if delete_csv:
            os.remove(self._full_filename)

    def __del__(self):
        if not self._file.closed:
            self._file.close()

    def __enter__(self):
        return self

    def __exit__(self, *unused):
        pass

class XlsManager(object):
    import xlwt  # pip

    def __init__(self, filename, mode='w', filedir='./'):
        """
        XlsManager(filename, mode='w', filedir='./')
        write xls
        todo: read xls
        """
        self._file = xlwt.Workbook()
        self._is_open = True
        # makedirs if not exsit
        filedir = os.path.abspath(filedir)
        os.makedirs(filedir) if not os.path.isdir(filedir) else True
        # create csv file
        filename += '.xls' if not filename.endswith('.xls') else ''
        self._full_filename = os.path.join(filedir, filename)

        self._style = xlwt.XFStyle()
        _font = xlwt.Font()
        _font.name = "SimSun"  # 'Times New Roman'
        _font.height = 220
        _font.charset = xlwt.Font.CHARSET_SYS_DEFAULT
        self._style.font = _font

        # num of sheet
        self._sheet_count = 0

        # create default sheet
        self._sheet_count += 1
        # add_sheet(sheetname, cell_overwrite_ok=False)
        self._sheet = self._file.add_sheet('sheet%s' % self._sheet_count,
                                           cell_overwrite_ok=True)
        self._row = 0
        self._col = 0

    def add_sheet(self):
        """
        sheet name start from sheet2
        """
        self._sheet_count += 1
        self._sheet = self._file.add_sheet('sheet%s' % self._sheet_count,
                                           cell_overwrite_ok=True)
        self._row = 0
        self._col = 0

    def writerow(self, *args):
        # write(r, c, label='', style=<xlwt.Style.XFStyle object>)
        items = lister(args, target_type=unicode)
        if items:
            for col, item in enumerate(items):
                self._sheet.write(self._row, col, item, self._style)
        self._row += 1
        self._col = col + 1

    def close(self):
        """
        save manually
        """
        # save(filename_or_stream)
        if self._is_open:
            self._file.save(self._full_filename)
            self._is_open = False

    def __del__(self):
        # save(filename_or_stream)
        if self._is_open:
            self._file.save(self._full_filename)
            self._is_open = False

    def __enter__(self):
        return self

    def __exit__(self, *unused):
        pass

class MySQLManager(object):

    def __init__(self, host, user, passwd, db, port=3306, charset='utf8'):
        """
        MySQLManager(host, user, passwd, db, port=3306, charset='utf8')
        <class>: Connect to mysql
        @host<str>
        @user<str>
        @passwd<str>
        @db<str>
        @port<int>
        @charset<str>: same in MySQLdb.connect
        """
        import MySQLdb  # pip / easy_install
        try:
            self._conn = MySQLdb.connect(host=host,
                                         user=user,
                                         passwd=passwd,
                                         db=db,
                                         port=port,
                                         charset=charset)
            self._curs = self._conn.cursor()
        except:
            raise

    def execute(self, sql, debug=False, **kwargs):
        """
        execute(self, sql, debug=False, **kwargs)
        Generate and execute sql
        @sql<str>: sql or sql model
        @kwargs<dict>: dict to decorate sql
        """
        try:
            sql = sql % kwargs
            self._curs.execute(sql)
            resp = self._curs.fetchall()
            if debug:
                print '<debug>', '\nresp:', resp, '\nsql:', sql
            return resp
        except:
            print sql
            print kwargs
            raise

    def commit(self):
        self._conn.commit()

    def close(self):
        """
        use it when you want to close it manually
        """
        try:
            self._conn.commit()
            self._curs.close()
            self._conn.close()
        except:
            pass

    def __del__(self):
        try:
            self._conn.commit()
            self._curs.close()
            self._conn.close()
        except:
            pass

    def __enter__(self):
        return self

    def __exit__(self, *unused):
        pass

class ZipManager(object):
    import zipfile

    def __init__(self, filename, mode='w', filedir='./', pwd=''):
        """
        ZipManager(filename, mode='w', filedir='./')
        <class>: read, write, or rewrite zipfile
        @filedir + @filename = abspath of zipfile to save zipfile in r_mode
        @filename<str>: *.zip
        @mode<str>: r, w, a
        @pwd<str>: password
        """
        _full_filename = os.path.join(filedir, filename)
        self._mode = mode
        self._pwd = pwd
        if self._mode in ('w', 'a'):
            os.path.makedirs(filedir) if not os.path.isdir(filedir) else None
            self._file = zipfile.ZipFile(_full_filename,
                                         self._mode,
                                         zipfile.ZIP_DEFLATED)
        elif self._mode in ('r',):
                self._file = zipfile(_full_filename, self._mode, pwd) if\
                    self._pwd else zipfile(_full_filename, self._mode)
        else:
            raise TypeError("zipfile model has no open_mode: %s" % self._mode)

    def write(self, zip_file='.*', zipdir='./', zipfolder=False):
        """
        write(self, zipdir='./', zip_file=None)
        write target file(s) to zip
        @zip_file<str>: from file(s), it can be re_type such as .*\.csv
        @zipdir<str>: from dir
        @zipfolder<bool>: zip folder or not
        """
        if self._mode in ('r',):
            raise TypeError("ZipManager have no write_function with \
                            open_mode: %s" % self._mode)

        # zip folder
        if zipfolder:
            zipdir_len = len(zipdir.rstrip(os.sep)) + 1
            for dirname, subdirs, files in os.walk(zipdir):
                for filename in files:
                    if re.search(zip_file, filename):
                        path = os.path.join(dirname, filename)
                        entry = path[zipdir_len:]
                        self._file.write(path, entry)

        #not zip folder
        else:
            for _item in glob.glob(os.path.join(zipdir, '*')):
                if re.search(zip_file, _item) and os.path.isfile(_item):
                    self._file.write(_item)

    def close(self):
        """
        use it when you want to close it manually
        """
        try:
            self._file.close()
        except:
            pass

    def __del__(self):
        try:
            self._file.close()
        except:
            pass

    def __enter__(self):
        return self

    def __exit__(self, *unused):
        pass

class EmailSender(object):
    import mailer  # pip
    import mimetypes

    def __init__(self, **kwargs):
        """
        easy to use mail
        @To<str_list>: list of users you want to send email
        @Subject<str>
        @Body<str or fileObject>
        @attach<filename or filename_list>
        @debug<str>: show warning msg or not
        @retype_body: if True, your body will be retype: line --> <p>line</p>
        """
        log_time = str(time.time())[:6]
        self.logger = logger('file', 'log_email_%s.log' % log_time, './tmp')
        self.logger.info('%s%s' % ('-' * 20, 'email start'))
        self.logger.info('%s%s' % ('-' * 20, time.ctime()))
        params = {}
        for key, value in kwargs.items():
            params[key.lower()] = value

        # message setting
        self._to        = params.get('to', [])
        self._subject   = params.get('subject', None)
        self._body      = params.get('body', None)
        self._attach    = params.get('attach', [])
        self._retype_body = params.get('retype_body', False)

        # mailer setting
        self._host      = params.get('host', None)
        self._usr       = params.get('usr', None)
        self._pwd       = params.get('pwd', None)

        # signature
        self._signature = params.get('signature', None)
        self._debug     = params.get('debug', False)

        # message
        _date           = time_builder(target_type='full_time')
        self._message   = mailer.Message(Date=_date, charset="utf-8")

    def send(self):
        """send email"""
        if not self._check():
            return False

        self._build_message()
        _sender = mailer.Mailer(host=self._host,
                                usr=self._usr,
                                port=self._port,
                                use_ssl=True,
                                pwd=self._pwd)
        try:
            _sender.send(self._message)
        except:
            self.logger.error("[Error] Something wrong when sending email")
            print ("[Error] Something wrong when sending email")
            raise
        self.logger.info('%s%s' % ('-' * 20, time.ctime()))
        self.logger.info('%s%s' % ('-' * 20, 'email end with success'))
        return True

    @property
    def pwd(self):
        return self._pwd

    @pwd.setter
    def pwd(self, value):
        if isinstance(value, (str, unicode)):
            self._pwd = str(value)
        else:
            self.logger.error("Str or unicode anticipated, \
                got %s" % type(value))
            raise TypeError("Str or unicode anticipated, got %s" % type(value))

    @property
    def usr(self):
        return self._usr

    @usr.setter
    def usr(self, value):
        """
        @value: usrname
        """
        # parse email server
        _resp = re.search("@(.*)", value.strip())
        if _resp:
            _server = _resp.group(1)
            # get server host and port
            _resp = carrot.EMAIL_SERVER.get(_server)
            if _resp:
                self._host = _resp['smtp']['host']
                self._port = _resp['smtp']['port'][0]
            else:
                self.logger.error("server error: %s" % _resp)
                raise KeyError("Email server not in carrot.py")
        else:
            self.logger.error("email error: %s" % value)
            raise KeyError("Invalid email address")

        _resp = carrot.EMAIL_ACCOUNT.get(value, None)
        if _resp:
            self._usr       = _resp['usr']
            self.logger.info('get usr: %s' % self._usr)
            self._pwd       = _resp['pwd']
            self.logger.info('get pwd from file')
            self._signature = _resp['signature']
        else:
            self._usr       = value
            self.logger.info('get usr: %s' % self._usr)
            self._pwd       = raw_input("Insert your email pwd:")
            self.logger.info('get pwd from input')
            self._signature = value

    @property
    def attach(self):
        return self._attach

    @attach.setter
    def attach(self, *args):
        """
        add attach to Mesage directly
        @args: filenames
        """
        for filename in lister(args):
            if os.path.isfile(filename):
                ext   = os.path.splitext(filename)[-1]
                mtype = mimetypes.types_map.get(ext)
                self.logger.info('get attach: %s' % filename)
                self._message.attach(filename=filename,
                                     cid=None,
                                     mimetype=(mtype if mtype else None),
                                     content=None,
                                     charset=None)
            else:
                self.logger.warning("%s is not a file" % value)
                print ("%s is not a file" % value)

    @property
    def to(self):
        return self._to

    @to.setter
    def to(self, *args):
        """
        @args: email address
        """
        for email in lister(args):
            if isinstance(email, (str, unicode)) and '@' in email:
                self._to.append(email)
                self.logger.info('get receiver: %s' % email)
            else:
                self.logger.error("Invalid email address: %s" % email)
                raise KeyError("Invalid email address: %s" % email)

    @property
    def subject(self):
        return self._subject

    @subject.setter
    def subject(self, value):
        if isinstance(value, (str, unicode)):
            self._subject = value
            self.logger.info('get subject: %s' % value)
        else:
            self.logger.error("Str or unicode anticipated, \
                got %s" % type(value))
            raise TypeError("Str or unicode anticipated, got %s" % type(value))

    @property
    def body(self):
        return self._body

    @body.setter
    def body(self, value):
        if isinstance(value, (str, unicode)):
            if os.path.isfile(value):
                value = open(value).read()
            if self._retype_body:
                self._body = '\n'.join(['<p>' + i.strip() + '</p>'
                                       for i in value.split('\n')])
            else:
                self._body = unicode(value)
            self.logger.info('get body: %s...' % value[:10])
        else:
            self.logger.error("Str or unicode anticipated, \
                got %s" % type(value))
            raise TypeError("Str or unicode anticipated, got %s" % type(value))

    def _check(self):
        error = 0
        # usr pwd to must be set
        error_msg = ""
        if not (self._pwd):
            error_msg += '[Error] pwd is empty%s' % os.linesep
            error += 1
        if not (self._to):
            error_msg += '[Error] To(reciever) is empty%s' % os.linesep
            error += 1

        if error:
            self.logger.error('At least %s parameters should be set: \
                %s' % (error, error_msg))
            print ('At least %s parameters should be set:' % error)
            print error_msg
            return False
        else:
            self.logger.info('check pwd and receiver down')
            return True

    def _build_message(self):
        """build mesage"""
        try:
            self._message.From    = self._usr
            self._message.To      = self._to
            self._message.Subject = self._subject
            _body_wrapper = {
                'body': self._body,
                'signature': self._signature,
            }
            _html_model = carrot.EMAIL_HTML_MODEL
            for key, value in _body_wrapper.items():
                _html_model = _html_model.replace('<!--%s-->' % key, value)
            self._message.Html = _html_model
            self.logger.info('build message down')
        except:
            self.logger.error('fail to build message')
            raise

def email_parser(raw_email):
    """parse email and return dict
    @raw_email str
    """
    import email
    msg = email.message_from_string(raw_email)
    # print msg.keys()
    return {
        'subject': msg.get("subject"),
        'from': msg.get('from'),
        'to': msg.get('to'),
        'date': msg.get('Date')
    }

class EmailGetter(object):
    import imaplib

    def __init__(self, **kwargs):
        """receive email"""
        log_time = str(time.time())[:6]
        self.logger = logger('file', 'log_email_%s.log' % log_time, './tmp')
        self.logger.info('%s%s' % ('-' * 20, 'email start'))
        self.logger.info('%s%s' % ('-' * 20, time.ctime()))
        params = {}
        for key, value in kwargs.items():
            params[key.lower()] = value
        self._usr = params.get('usr', None)
        self._pwd = params.get('pwd', None)

    @property
    def usr(self):
        return self._usr

    @usr.setter
    def usr(self, value):
        """
        @value: usrname
        """
        # parse email server
        _resp = re.search("@(.*)", value.strip())
        if _resp:
            _server = _resp.group(1)
            # get server host and port
            _resp = carrot.EMAIL_SERVER.get(_server)
            if _resp:
                self._host = _resp['imap']['host']
                self._port = _resp['imap']['port'][0]
            else:
                self.logger.error("server error: %s" % _resp)
                raise KeyError("Email server not in carrot.py")
        else:
            self.logger.error("email error: %s" % value)
            raise KeyError("Invalid email address")

        _resp = carrot.EMAIL_ACCOUNT.get(value, None)
        if _resp:
            self._usr = _resp['usr']
            self.logger.info('get usr: %s' % self._usr)
            self._pwd = _resp['pwd']
            self.logger.info('get pwd from file')
        else:
            self._usr = value
            self.logger.info('get usr: %s' % self._usr)
            self._pwd = raw_input("Insert your email pwd:")
            self.logger.info('get pwd from input')

    @property
    def pwd(self):
        return self._pwd

    @pwd.setter
    def pwd(self, value):
        if isinstance(value, (str, unicode)):
            self._pwd = str(value)
        else:
            self.logger.error("Str or unicode anticipated, \
                got %s" % type(value))
            raise TypeError("Str or unicode anticipated, got %s" % type(value))

    def get(self):
        """
        return email list
        """
        self.logger.info("connect to host %s: %s" % (self._host, self._port))
        self.M = imaplib.IMAP4_SSL(self._host, self._port)
        self.logger.info("login with usr %s" % self._usr)
        try:
            self.M.login(self._usr, self._pwd)
        except:
            raise
        self.logger.info("use INBOX")
        self.M.select("INBOX")
        self.logger.info("search new email %s" % self._usr)
        # typ, data = self.M.uid("SEARCH", "UNSEEN")
        typ, data = self.M.search(None, "UNSEEN")
        # time_builder(timedelta=-10, target_type='dbY-'))
        if typ == "OK":
            for uid in data[0].split():
                result, raw_email = self.M.fetch(uid, "(RFC822)")
                    # uid("FETCH", uid, "ALL")
                          # "(FLAGS BODY.PEEK[HEADER] BODYSTRUCTURE)")
                if result:
                    # self.M.store(uid, '+FLAGS', '\\Seen')  # mark as read
                    print email_parser(raw_email[0][1])
                    # for i in raw_email:
                    #     print i
        # print self._usr, self._pwd, self._host, self._port

    def close(self):
        try:
            self.M.logout()
        except:
            raise

    def mark(self, select_day, status):
        """todo use to mark emails"""
        pass
        # typ, data = M.search(None, '(BEFORE 01-Jan-2009)')
        # for num in data[0].split():
        #    M.store(num, '+FLAGS', '\\Seen')

# @func_monitor(True)
def test_func():
    x, y = 1, 2
    return x + y

if __name__ == '__main__':
    # print filesplitter(sys.argv[1])
    args = docopt(__doc__)
    # print args
    if args.get('test'):
        jobs = []
        for i in range(9999):
            jobs.append((test_func, ()))
        p = PoolManager(jobs)
        p.run()
    elif args.get('imgetter'):
        imgetter(args.get('<url>'), args.get('<savedir>'))
    elif args.get('splitfile'):
        filesplitter(args.get('<file_or_dir>'), size=args.get('<size>'))
    elif args.get('urljoin'):
        print xurljoin(args.get('<baseurl>'), args.get('<url>'))

    # emailget = EmailGetter()
    # emailget.usr = 'test@itprofessor.cn'
    # emailget.get()
    # emailget.close()

    # from optparse import OptionParser
    # usage = """%prog [-e <email>]"""
    # version = "%prog 1.0"
    # parser = OptionParser(usage=usage)
    # parser.add_option('-e', '--email',
    #                   dest='email',
    #                   help="-e usrname@example.com",
    #                   action="store_true")
    # (options, args) = parser.parse_args()
    # if options.email and args:
    #     a    = EmailSender()
    #     a.to = args
    #     # a.attach = './carrot.py'
    #     # a.attach = './rabbit.py'
    #     a.send()
    # else:
    #     raise ValueError("python rabbit.py -e <your_email>")
    # xlsapp = XlsManager('test.xls', 'w')
    # xlsapp.writerow(1, 2, 3, 4, 5)
    # xlsapp.close()

    # emailapp         = EmailSender()
    # emailapp.usr     = 'test@itprofessor.cn'
    # emailapp.to      = ['admin@wlfei.com', 'basicworld@163.com']
    # emailapp.subject = 'hello you'
    # emailapp.body    = """abc"""
    # emailapp.attach = ('rabbit.py', 'carrot.py')
    # emailapp.send()

    # csvapp = CsvManager('test.csv')
    # csvapp.writerow('122', '2')
    # csvapp.writerow('中文', 1, 2, 3)
    # csvapp.csv2xls()
    pass


text:
package esiv2

/*
Summary of victory points gained by the given character for the enlisted faction */
type GetCharactersCharacterIdFwStatsVictoryPoints struct {
	/*
	 Last week's victory points gained by the given character */
	LastWeek int32 `json:"last_week,omitempty"`
	/*
	 Total victory points gained since the given character enlisted */
	Total int32 `json:"total,omitempty"`
	/*
	 Yesterday's victory points gained by the given character */
	Yesterday int32 `json:"yesterday,omitempty"`
}


text:
package org.innovateuk.ifs.user.service;

import org.innovateuk.ifs.commons.rest.RestResult;
import org.innovateuk.ifs.organisation.resource.OrganisationSearchResult;

import java.util.List;

public interface OrganisationSearchRestService {
    RestResult<List<OrganisationSearchResult>> searchOrganisation(Long organisationTypeId, String organisationSearchText, int indexPos);

    RestResult<OrganisationSearchResult> getOrganisation(Long organisationTypeId, String searchOrganisationId);

    RestResult<List<OrganisationSearchResult>> searchOrganisation(Enum<?> organisationType, String organisationSearchText, int indexPos);

    RestResult<OrganisationSearchResult> getOrganisation(Enum<?> organisationType, String searchOrganisationId);
}


text:
package org.apache.cassandra.serializers;

import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.ByteBufferAccessor;
import org.apache.cassandra.db.marshal.ValueAccessor;
import org.apache.cassandra.db.marshal.ValueComparators;
import org.apache.cassandra.transport.ProtocolVersion;
import org.apache.cassandra.utils.Pair;

public class MapSerializer<K, V> extends AbstractMapSerializer<Map<K, V>>
{
    // interning instances
    @SuppressWarnings("rawtypes")
    private static final ConcurrentMap<Pair<TypeSerializer<?>, TypeSerializer<?>>, MapSerializer> instances = new ConcurrentHashMap<>();

    public final TypeSerializer<K> keys;
    public final TypeSerializer<V> values;
    private final ValueComparators comparators;

    @SuppressWarnings("unchecked")
    public static <K, V> MapSerializer<K, V> getInstance(TypeSerializer<K> keys, TypeSerializer<V> values, ValueComparators comparators)
    {
        Pair<TypeSerializer<?>, TypeSerializer<?>> p = Pair.create(keys, values);
        MapSerializer<K, V> t = instances.get(p);
        if (t == null)
            t = instances.computeIfAbsent(p, k -> new MapSerializer<>(k.left, k.right, comparators) );
        return t;
    }

    private MapSerializer(TypeSerializer<K> keys, TypeSerializer<V> values, ValueComparators comparators)
    {
        super(true);
        this.keys = keys;
        this.values = values;
        this.comparators = comparators;
    }

    public List<ByteBuffer> serializeValues(Map<K, V> map)
    {
        List<Pair<ByteBuffer, ByteBuffer>> pairs = new ArrayList<>(map.size());
        for (Map.Entry<K, V> entry : map.entrySet())
            pairs.add(Pair.create(keys.serialize(entry.getKey()), values.serialize(entry.getValue())));
        pairs.sort((l, r) -> comparators.buffer.compare(l.left, r.left));
        List<ByteBuffer> buffers = new ArrayList<>(pairs.size() * 2);
        for (Pair<ByteBuffer, ByteBuffer> p : pairs)
        {
            buffers.add(p.left);
            buffers.add(p.right);
        }
        return buffers;
    }

    public int getElementCount(Map<K, V> value)
    {
        return value.size();
    }

    public <T> void validateForNativeProtocol(T input, ValueAccessor<T> accessor, ProtocolVersion version)
    {
        try
        {
            // Empty values are still valid.
            if (accessor.isEmpty(input)) return;

            int n = readCollectionSize(input, accessor, version);
            int offset = sizeOfCollectionSize(n, version);
            for (int i = 0; i < n; i++)
            {
                T key = readValue(input, accessor, offset, version);
                offset += sizeOfValue(key, accessor, version);
                keys.validate(key, accessor);

                T value = readValue(input, accessor, offset, version);
                offset += sizeOfValue(value, accessor, version);
                values.validate(value, accessor);
            }
            if (!accessor.isEmptyFromOffset(input, offset))
                throw new MarshalException("Unexpected extraneous bytes after map value");
        }
        catch (BufferUnderflowException | IndexOutOfBoundsException e)
        {
            throw new MarshalException("Not enough bytes to read a map");
        }
    }

    public <I> Map<K, V> deserializeForNativeProtocol(I input, ValueAccessor<I> accessor, ProtocolVersion version)
    {
        try
        {
            int n = readCollectionSize(input, accessor, version);
            int offset = sizeOfCollectionSize(n, version);

            if (n < 0)
                throw new MarshalException("The data cannot be deserialized as a map");

            // If the received bytes are not corresponding to a map, n might be a huge number.
            // In such a case we do not want to initialize the map with that initialCapacity as it can result
            // in an OOM when put is called (see CASSANDRA-12618). On the other hand we do not want to have to resize
            // the map if we can avoid it, so we put a reasonable limit on the initialCapacity.
            Map<K, V> m = new LinkedHashMap<>(Math.min(n, 256));
            for (int i = 0; i < n; i++)
            {
                I key = readValue(input, accessor, offset, version);
                offset += sizeOfValue(key, accessor, version);
                keys.validate(key, accessor);

                I value = readValue(input, accessor, offset, version);
                offset += sizeOfValue(value, accessor, version);
                values.validate(value, accessor);

                m.put(keys.deserialize(key, accessor), values.deserialize(value, accessor));
            }
            if (!accessor.isEmptyFromOffset(input, offset))
                throw new MarshalException("Unexpected extraneous bytes after map value");
            return m;
        }
        catch (BufferUnderflowException | IndexOutOfBoundsException e)
        {
            throw new MarshalException("Not enough bytes to read a map");
        }
    }

    @Override
    public ByteBuffer getSerializedValue(ByteBuffer collection, ByteBuffer key, AbstractType<?> comparator)
    {
        try
        {
            ByteBuffer input = collection.duplicate();
            int n = readCollectionSize(input, ByteBufferAccessor.instance, ProtocolVersion.V3);
            int offset = sizeOfCollectionSize(n, ProtocolVersion.V3);
            for (int i = 0; i < n; i++)
            {
                ByteBuffer kbb = readValue(input, ByteBufferAccessor.instance, offset, ProtocolVersion.V3);
                offset += sizeOfValue(kbb, ByteBufferAccessor.instance, ProtocolVersion.V3);
                int comparison = comparator.compareForCQL(kbb, key);
                if (comparison == 0)
                    return readValue(input, ByteBufferAccessor.instance, offset, ProtocolVersion.V3);
                else if (comparison > 0)
                    // since the map is in sorted order, we know we've gone too far and the element doesn't exist
                    return null;
                else // comparison < 0
                    offset += skipValue(input, ByteBufferAccessor.instance, offset, ProtocolVersion.V3);
            }
            return null;
        }
        catch (BufferUnderflowException | IndexOutOfBoundsException e)
        {
            throw new MarshalException("Not enough bytes to read a map");
        }
    }

    public String toString(Map<K, V> value)
    {
        StringBuilder sb = new StringBuilder();
        sb.append('{');
        boolean isFirst = true;
        for (Map.Entry<K, V> element : value.entrySet())
        {
            if (isFirst)
                isFirst = false;
            else
                sb.append(", ");
            sb.append(keys.toString(element.getKey()));
            sb.append(": ");
            sb.append(values.toString(element.getValue()));
        }
        sb.append('}');
        return sb.toString();
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public Class<Map<K, V>> getType()
    {
        return (Class) Map.class;
    }
}


text:
angular.module('app.history_controller', []).controller('historyCtrl', function($scope, $state, repository, $rootScope) {

  $rootScope.navActive = 'history'
  $scope.commits = []
  $scope.loading = false

  const commits_to_show = 200

  init()
  .then(() => {
    $scope.loading = false
    $scope.$apply()
  })

  $scope.showDiff = (commit) => {
    const commitId = commit.id().toString()
    $state.go('repository.commit', {
      id: commitId
    })
  }

  function init() {
    $scope.loading = true
    return repository.git.getCommits(commits_to_show)
    .then((commits) => {
      $scope.commits = commits
      commits.forEach(commit => {
        commit.date = moment(commit.date()).fromNow()
        commit.msg = commit.message()
      })
    })
  }

})


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

    <!-- load other contexts (basically: core) -->
    <!--import resource="classpath:applicationContext.xml" /-->
    <context:annotation-config/>
    <context:component-scan base-package="de.kreggel.*" scope-resolver="org.springframework.context.annotation.Jsr330ScopeMetadataResolver"/>
</beans>


text:
from django.test import TestCase
from django.test.client import Client
from django.core.urlresolvers import reverse

## Unit Tests
## TODO: How to test ImageFields?

## Doctests to describe the app
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.

>>> 1 + 1 == 2
True
"""}


text: Wi-Fi Direct with Spontaneous Connection


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EDDA: test/test_distribution.cpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="search/search.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

EDDA

test

Functions

test_distribution.cpp File Reference

#include <cstdlib>

#include <ctime>

#include <iostream>

#include "distributions/distribution.h"

#include "distributions/variant.h"

#include "dataset/distr_array.h"

Functions

DefaultGaussianMixture 	gen_gmm ()

GaussianMixture< 2 > 	gen_gmm2 ()

DistrArray * 	make_Gaussian_array ()

DistrArray * 	make_GMM_array ()

DistrArray * 	make_GMM2_array ()

DistrArray * 	make_hybrid_array ()

DistrArray * 	make_JointGaussian_array ()

DistrArray * 	make_JointHistogram_array ()

int 	main ()

Function Documentation

§ gen_gmm()

          DefaultGaussianMixture gen_gmm
          (
          	)

§ gen_gmm2()

          GaussianMixture<2> gen_gmm2
          (
          	)

§ main()

          int main
          (
          	)

§ make_Gaussian_array()

          DistrArray* make_Gaussian_array
          (
          	)

§ make_GMM2_array()

          DistrArray* make_GMM2_array
          (
          	)

§ make_GMM_array()

          DistrArray* make_GMM_array
          (
          	)

§ make_hybrid_array()

          DistrArray* make_hybrid_array
          (
          	)

§ make_JointGaussian_array()

          DistrArray* make_JointGaussian_array
          (
          	)

§ make_JointHistogram_array()

          DistrArray* make_JointHistogram_array
          (
          	)

<address class="footer">
Generated on Tue Nov 15 2016 16:22:27 for EDDA by

 1.8.12
</address>


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using SaanSoft.AspNet.Identity3.MongoDB;
using Web.MongoDBIdentitySample.Models;
using Web.MongoDBIdentitySample.Services;

namespace Web.MongoDBIdentitySample
{
	public class Startup
	{
		public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
		{
			// Set up configuration sources.
			var builder = new ConfigurationBuilder()
				.SetBasePath(appEnv.ApplicationBasePath)
				.AddJsonFile("appsettings.json")
				.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
				.AddEnvironmentVariables();

			if (env.IsDevelopment())
			{
				// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
				builder.AddUserSecrets();
			}

			Configuration = builder.Build();
		}

		public IConfigurationRoot Configuration { get; set; }

		// This method gets called by the runtime. Use this method to add services to the container.
		public void ConfigureServices(IServiceCollection services)
		{
			// Registers MongoDB conventions for ignoring default and blank fields
			// NOTE: if you have registered default conventions elsewhere, probably don't need to do this
			RegisterClassMap<ApplicationUser, IdentityRole, string>.Init();

			// Add Mongo Identity services to the services container.
			// registers all of the interfaces it implements to the services as "Scoped"
			services.AddIdentity<ApplicationUser, IdentityRole>()
					.AddMongoDBIdentityStores<ApplicationDbContext, ApplicationUser, IdentityRole, string>(options =>
					{
						options.ConnectionString = Configuration["Data:DefaultConnection:ConnectionString"];        // No default, must be configured if using (eg "mongodb://localhost:27017" in this project's appsettings.json)
																													// Only required if need to create [Client] from the connection string
																													// If you are providing the [Client] or [Database] or [UserCollection] and [RoleCollection] options instead, don't need to supply [ConnectionString]
						// options.Client = [IMongoClient];									// Defaults to: uses either Client attached to [Database] (if supplied), otherwise it creates a new client using [ConnectionString]
						// options.DatabaseName = [string];									// Defaults to: "AspNetIdentity"
						// options.Database = [IMongoDatabase];								// Defaults to: Creating Database using [DatabaseName] and [Client]

						// options.UserCollectionName = [string];							// Defaults to: "AspNetUsers"
						// options.RoleCollectionName = [string];							// Defaults to: "AspNetRoles"
						// options.UserCollection = [IMongoCollection<TUser>];				// Defaults to: Creating user collection in [Database] using [UserCollectionName] and [CollectionSettings]
						// options.RoleCollection = [IMongoCollection<TRole>];				// Defaults to: Creating user collection in [Database] using [RoleCollectionName] and [CollectionSettings]
						// options.CollectionSettings = [MongoCollectionSettings];			// Defaults to: { WriteConcern = WriteConcern.WMajority } => Used when creating default [UserCollection] and [RoleCollection]

						// options.EnsureCollectionIndexes = [bool];						// Defaults to: false => Used to ensure the User and Role collections have been created in MongoDB and indexes assigned. Only runs on first calls to user and role collections.
						// options.CreateCollectionOptions = [CreateCollectionOptions];		// Defaults to: { AutoIndexId = true } => Used when [EnsureCollectionIndexes] is true and User or Role collections need to be created.
						// options.CreateIndexOptions = [CreateIndexOptions];				// Defaults to: { Background = true, Sparse = true } => Used when [EnsureCollectionIndexes] is true and any indexes need to be created.
					})
					.AddDefaultTokenProviders();

			// Add MVC services to the services container.
			services.AddMvc();

			// Add application services.
			services.AddTransient<IEmailSender, AuthMessageSender>();
			services.AddTransient<ISmsSender, AuthMessageSender>();
		}

		// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
		public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
		{
			loggerFactory.AddConsole(Configuration.GetSection("Logging"));
			loggerFactory.AddDebug();

			if (env.IsDevelopment())
			{
				//app.UseBrowserLink();
				app.UseDeveloperExceptionPage(new ErrorPageOptions { SourceCodeLineCount = 20});
			}
			else
			{
				app.UseExceptionHandler("/Home/Error");
			}

			app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

			app.UseStaticFiles();

			app.UseIdentity();

			// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715

			app.UseMvc(routes =>
			{
				routes.MapRoute(
					name: "default",
					template: "{controller=Home}/{action=Index}/{id?}");
			});
		}

		// Entry point for the application.
		public static void Main(string[] args) => WebApplication.Run<Startup>(args);
	}
}