text:
package org.elasticsearch.common.network;

import java.util.Arrays;
import java.util.List;

import org.elasticsearch.action.support.replication.ReplicationTask;
import org.elasticsearch.client.transport.TransportClientNodesService;
import org.elasticsearch.client.transport.support.TransportProxyClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.ExtensionPoint;
import org.elasticsearch.http.HttpServer;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.http.netty.NettyHttpServerTransport;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.rest.action.admin.cluster.health.RestClusterHealthAction;
import org.elasticsearch.rest.action.admin.cluster.node.hotthreads.RestNodesHotThreadsAction;
import org.elasticsearch.rest.action.admin.cluster.node.info.RestNodesInfoAction;
import org.elasticsearch.rest.action.admin.cluster.node.stats.RestNodesStatsAction;
import org.elasticsearch.rest.action.admin.cluster.node.tasks.RestCancelTasksAction;
import org.elasticsearch.rest.action.admin.cluster.node.tasks.RestListTasksAction;
import org.elasticsearch.rest.action.admin.cluster.repositories.delete.RestDeleteRepositoryAction;
import org.elasticsearch.rest.action.admin.cluster.repositories.get.RestGetRepositoriesAction;
import org.elasticsearch.rest.action.admin.cluster.repositories.put.RestPutRepositoryAction;
import org.elasticsearch.rest.action.admin.cluster.repositories.verify.RestVerifyRepositoryAction;
import org.elasticsearch.rest.action.admin.cluster.reroute.RestClusterRerouteAction;
import org.elasticsearch.rest.action.admin.cluster.settings.RestClusterGetSettingsAction;
import org.elasticsearch.rest.action.admin.cluster.settings.RestClusterUpdateSettingsAction;
import org.elasticsearch.rest.action.admin.cluster.shards.RestClusterSearchShardsAction;
import org.elasticsearch.rest.action.admin.cluster.snapshots.create.RestCreateSnapshotAction;
import org.elasticsearch.rest.action.admin.cluster.snapshots.delete.RestDeleteSnapshotAction;
import org.elasticsearch.rest.action.admin.cluster.snapshots.get.RestGetSnapshotsAction;
import org.elasticsearch.rest.action.admin.cluster.snapshots.restore.RestRestoreSnapshotAction;
import org.elasticsearch.rest.action.admin.cluster.snapshots.status.RestSnapshotsStatusAction;
import org.elasticsearch.rest.action.admin.cluster.state.RestClusterStateAction;
import org.elasticsearch.rest.action.admin.cluster.stats.RestClusterStatsAction;
import org.elasticsearch.rest.action.admin.cluster.tasks.RestPendingClusterTasksAction;
import org.elasticsearch.rest.action.admin.indices.alias.RestIndicesAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.delete.RestIndexDeleteAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.get.RestGetAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.get.RestGetIndicesAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.head.RestAliasesExistAction;
import org.elasticsearch.rest.action.admin.indices.alias.put.RestIndexPutAliasAction;
import org.elasticsearch.rest.action.admin.indices.analyze.RestAnalyzeAction;
import org.elasticsearch.rest.action.admin.indices.cache.clear.RestClearIndicesCacheAction;
import org.elasticsearch.rest.action.admin.indices.close.RestCloseIndexAction;
import org.elasticsearch.rest.action.admin.indices.create.RestCreateIndexAction;
import org.elasticsearch.rest.action.admin.indices.delete.RestDeleteIndexAction;
import org.elasticsearch.rest.action.admin.indices.exists.indices.RestIndicesExistsAction;
import org.elasticsearch.rest.action.admin.indices.exists.types.RestTypesExistsAction;
import org.elasticsearch.rest.action.admin.indices.flush.RestFlushAction;
import org.elasticsearch.rest.action.admin.indices.flush.RestSyncedFlushAction;
import org.elasticsearch.rest.action.admin.indices.forcemerge.RestForceMergeAction;
import org.elasticsearch.rest.action.admin.indices.get.RestGetIndicesAction;
import org.elasticsearch.rest.action.admin.indices.mapping.get.RestGetFieldMappingAction;
import org.elasticsearch.rest.action.admin.indices.mapping.get.RestGetMappingAction;
import org.elasticsearch.rest.action.admin.indices.mapping.put.RestPutMappingAction;
import org.elasticsearch.rest.action.admin.indices.open.RestOpenIndexAction;
import org.elasticsearch.rest.action.admin.indices.recovery.RestRecoveryAction;
import org.elasticsearch.rest.action.admin.indices.refresh.RestRefreshAction;
import org.elasticsearch.rest.action.admin.indices.segments.RestIndicesSegmentsAction;
import org.elasticsearch.rest.action.admin.indices.settings.RestGetSettingsAction;
import org.elasticsearch.rest.action.admin.indices.settings.RestUpdateSettingsAction;
import org.elasticsearch.rest.action.admin.indices.shards.RestIndicesShardStoresAction;
import org.elasticsearch.rest.action.admin.indices.stats.RestIndicesStatsAction;
import org.elasticsearch.rest.action.admin.indices.template.delete.RestDeleteIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.template.head.RestHeadIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.template.put.RestPutIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.upgrade.RestUpgradeAction;
import org.elasticsearch.rest.action.admin.indices.validate.query.RestValidateQueryAction;
import org.elasticsearch.rest.action.admin.indices.validate.template.RestRenderSearchTemplateAction;
import org.elasticsearch.rest.action.bulk.RestBulkAction;
import org.elasticsearch.rest.action.cat.AbstractCatAction;
import org.elasticsearch.rest.action.cat.RestAliasAction;
import org.elasticsearch.rest.action.cat.RestAllocationAction;
import org.elasticsearch.rest.action.cat.RestCatAction;
import org.elasticsearch.rest.action.cat.RestFielddataAction;
import org.elasticsearch.rest.action.cat.RestHealthAction;
import org.elasticsearch.rest.action.cat.RestIndicesAction;
import org.elasticsearch.rest.action.cat.RestMasterAction;
import org.elasticsearch.rest.action.cat.RestNodeAttrsAction;
import org.elasticsearch.rest.action.cat.RestNodesAction;
import org.elasticsearch.rest.action.cat.RestPluginsAction;
import org.elasticsearch.rest.action.cat.RestRepositoriesAction;
import org.elasticsearch.rest.action.cat.RestSegmentsAction;
import org.elasticsearch.rest.action.cat.RestShardsAction;
import org.elasticsearch.rest.action.cat.RestSnapshotAction;
import org.elasticsearch.rest.action.cat.RestThreadPoolAction;
import org.elasticsearch.rest.action.delete.RestDeleteAction;
import org.elasticsearch.rest.action.explain.RestExplainAction;
import org.elasticsearch.rest.action.fieldstats.RestFieldStatsAction;
import org.elasticsearch.rest.action.get.RestGetAction;
import org.elasticsearch.rest.action.get.RestGetSourceAction;
import org.elasticsearch.rest.action.get.RestHeadAction;
import org.elasticsearch.rest.action.get.RestMultiGetAction;
import org.elasticsearch.rest.action.index.RestIndexAction;
import org.elasticsearch.rest.action.ingest.RestDeletePipelineAction;
import org.elasticsearch.rest.action.ingest.RestGetPipelineAction;
import org.elasticsearch.rest.action.ingest.RestPutPipelineAction;
import org.elasticsearch.rest.action.ingest.RestSimulatePipelineAction;
import org.elasticsearch.rest.action.main.RestMainAction;
import org.elasticsearch.rest.action.percolate.RestMultiPercolateAction;
import org.elasticsearch.rest.action.percolate.RestPercolateAction;
import org.elasticsearch.rest.action.script.RestDeleteIndexedScriptAction;
import org.elasticsearch.rest.action.script.RestGetIndexedScriptAction;
import org.elasticsearch.rest.action.script.RestPutIndexedScriptAction;
import org.elasticsearch.rest.action.search.RestClearScrollAction;
import org.elasticsearch.rest.action.search.RestMultiSearchAction;
import org.elasticsearch.rest.action.search.RestSearchAction;
import org.elasticsearch.rest.action.search.RestSearchScrollAction;
import org.elasticsearch.rest.action.suggest.RestSuggestAction;
import org.elasticsearch.rest.action.template.RestDeleteSearchTemplateAction;
import org.elasticsearch.rest.action.template.RestGetSearchTemplateAction;
import org.elasticsearch.rest.action.template.RestPutSearchTemplateAction;
import org.elasticsearch.rest.action.termvectors.RestMultiTermVectorsAction;
import org.elasticsearch.rest.action.termvectors.RestTermVectorsAction;
import org.elasticsearch.rest.action.update.RestUpdateAction;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.local.LocalTransport;
import org.elasticsearch.transport.netty.NettyTransport;

/**
 * A module to handle registering and binding all network related classes.
 */
public class NetworkModule extends AbstractModule {

    public static final String TRANSPORT_TYPE_KEY = "transport.type";
    public static final String TRANSPORT_SERVICE_TYPE_KEY = "transport.service.type";
    public static final String HTTP_TYPE_KEY = "http.type";
    public static final String LOCAL_TRANSPORT = "local";
    public static final String NETTY_TRANSPORT = "netty";

    public static final Setting<String> HTTP_TYPE_SETTING = Setting.simpleString("http.type", Property.NodeScope);
    public static final Setting<Boolean> HTTP_ENABLED = Setting.boolSetting("http.enabled", true, Property.NodeScope);
    public static final Setting<String> TRANSPORT_SERVICE_TYPE_SETTING =
        Setting.simpleString("transport.service.type", Property.NodeScope);
    public static final Setting<String> TRANSPORT_TYPE_SETTING = Setting.simpleString("transport.type", Property.NodeScope);

    private static final List<Class<? extends RestHandler>> builtinRestHandlers = Arrays.asList(
        RestMainAction.class,
        RestNodesInfoAction.class,
        RestNodesStatsAction.class,
        RestNodesHotThreadsAction.class,
        RestClusterStatsAction.class,
        RestClusterStateAction.class,
        RestClusterHealthAction.class,
        RestClusterUpdateSettingsAction.class,
        RestClusterGetSettingsAction.class,
        RestClusterRerouteAction.class,
        RestClusterSearchShardsAction.class,
        RestPendingClusterTasksAction.class,
        RestPutRepositoryAction.class,
        RestGetRepositoriesAction.class,
        RestDeleteRepositoryAction.class,
        RestVerifyRepositoryAction.class,
        RestGetSnapshotsAction.class,
        RestCreateSnapshotAction.class,
        RestRestoreSnapshotAction.class,
        RestDeleteSnapshotAction.class,
        RestSnapshotsStatusAction.class,

        RestIndicesExistsAction.class,
        RestTypesExistsAction.class,
        RestGetIndicesAction.class,
        RestIndicesStatsAction.class,
        RestIndicesSegmentsAction.class,
        RestIndicesShardStoresAction.class,
        RestGetAliasesAction.class,
        RestAliasesExistAction.class,
        RestIndexDeleteAliasesAction.class,
        RestIndexPutAliasAction.class,
        RestIndicesAliasesAction.class,
        RestGetIndicesAliasesAction.class,
        RestCreateIndexAction.class,
        RestDeleteIndexAction.class,
        RestCloseIndexAction.class,
        RestOpenIndexAction.class,

        RestUpdateSettingsAction.class,
        RestGetSettingsAction.class,

        RestAnalyzeAction.class,
        RestGetIndexTemplateAction.class,
        RestPutIndexTemplateAction.class,
        RestDeleteIndexTemplateAction.class,
        RestHeadIndexTemplateAction.class,

        RestPutMappingAction.class,
        RestGetMappingAction.class,
        RestGetFieldMappingAction.class,

        RestRefreshAction.class,
        RestFlushAction.class,
        RestSyncedFlushAction.class,
        RestForceMergeAction.class,
        RestUpgradeAction.class,
        RestClearIndicesCacheAction.class,

        RestIndexAction.class,
        RestGetAction.class,
        RestGetSourceAction.class,
        RestHeadAction.class,
        RestMultiGetAction.class,
        RestDeleteAction.class,
        org.elasticsearch.rest.action.count.RestCountAction.class,
        RestSuggestAction.class,
        RestTermVectorsAction.class,
        RestMultiTermVectorsAction.class,
        RestBulkAction.class,
        RestUpdateAction.class,
        RestPercolateAction.class,
        RestMultiPercolateAction.class,

        RestSearchAction.class,
        RestSearchScrollAction.class,
        RestClearScrollAction.class,
        RestMultiSearchAction.class,
        RestRenderSearchTemplateAction.class,

        RestValidateQueryAction.class,

        RestExplainAction.class,

        RestRecoveryAction.class,

        // Templates API
        RestGetSearchTemplateAction.class,
        RestPutSearchTemplateAction.class,
        RestDeleteSearchTemplateAction.class,

        // Scripts API
        RestGetIndexedScriptAction.class,
        RestPutIndexedScriptAction.class,
        RestDeleteIndexedScriptAction.class,

        RestFieldStatsAction.class,

        // no abstract cat action
        RestCatAction.class,

        // Tasks API
        RestListTasksAction.class,
        RestCancelTasksAction.class,

        // Ingest API
        RestPutPipelineAction.class,
        RestGetPipelineAction.class,
        RestDeletePipelineAction.class,
        RestSimulatePipelineAction.class
    );

    private static final List<Class<? extends AbstractCatAction>> builtinCatHandlers = Arrays.asList(
        RestAllocationAction.class,
        RestShardsAction.class,
        RestMasterAction.class,
        RestNodesAction.class,
        RestIndicesAction.class,
        RestSegmentsAction.class,
        // Fully qualified to prevent interference with rest.action.count.RestCountAction
        org.elasticsearch.rest.action.cat.RestCountAction.class,
        // Fully qualified to prevent interference with rest.action.indices.RestRecoveryAction
        org.elasticsearch.rest.action.cat.RestRecoveryAction.class,
        RestHealthAction.class,
        org.elasticsearch.rest.action.cat.RestPendingClusterTasksAction.class,
        RestAliasAction.class,
        RestThreadPoolAction.class,
        RestPluginsAction.class,
        RestFielddataAction.class,
        RestNodeAttrsAction.class,
        RestRepositoriesAction.class,
        RestSnapshotAction.class
    );

    private final NetworkService networkService;
    private final Settings settings;
    private final boolean transportClient;

    private final ExtensionPoint.SelectedType<TransportService> transportServiceTypes = new ExtensionPoint.SelectedType<>("transport_service", TransportService.class);
    private final ExtensionPoint.SelectedType<Transport> transportTypes = new ExtensionPoint.SelectedType<>("transport", Transport.class);
    private final ExtensionPoint.SelectedType<HttpServerTransport> httpTransportTypes = new ExtensionPoint.SelectedType<>("http_transport", HttpServerTransport.class);
    private final ExtensionPoint.ClassSet<RestHandler> restHandlers = new ExtensionPoint.ClassSet<>("rest_handler", RestHandler.class);
    // we must separate the cat rest handlers so RestCatAction can collect them...
    private final ExtensionPoint.ClassSet<AbstractCatAction> catHandlers = new ExtensionPoint.ClassSet<>("cat_handler", AbstractCatAction.class);
    private final NamedWriteableRegistry namedWriteableRegistry;

    /**
     * Creates a network module that custom networking classes can be plugged into.
     *
     * @param networkService A constructed network service object to bind.
     * @param settings The settings for the node
     * @param transportClient True if only transport classes should be allowed to be registered, false otherwise.
     * @param namedWriteableRegistry registry for named writeables for use during streaming
     */
    public NetworkModule(NetworkService networkService, Settings settings, boolean transportClient, NamedWriteableRegistry namedWriteableRegistry) {
        this.networkService = networkService;
        this.settings = settings;
        this.transportClient = transportClient;
        this.namedWriteableRegistry = namedWriteableRegistry;
        registerTransportService(NETTY_TRANSPORT, TransportService.class);
        registerTransport(LOCAL_TRANSPORT, LocalTransport.class);
        registerTransport(NETTY_TRANSPORT, NettyTransport.class);
        registerTaskStatus(ReplicationTask.Status.NAME, ReplicationTask.Status::new);

        if (transportClient == false) {
            registerHttpTransport(NETTY_TRANSPORT, NettyHttpServerTransport.class);

            for (Class<? extends AbstractCatAction> catAction : builtinCatHandlers) {
                catHandlers.registerExtension(catAction);
            }
            for (Class<? extends RestHandler> restAction : builtinRestHandlers) {
                restHandlers.registerExtension(restAction);
            }
        }
    }

    /** Adds a transport service implementation that can be selected by setting {@link #TRANSPORT_SERVICE_TYPE_KEY}. */
    public void registerTransportService(String name, Class<? extends TransportService> clazz) {
        transportServiceTypes.registerExtension(name, clazz);
    }

    /** Adds a transport implementation that can be selected by setting {@link #TRANSPORT_TYPE_KEY}. */
    public void registerTransport(String name, Class<? extends Transport> clazz) {
        transportTypes.registerExtension(name, clazz);
    }

    /** Adds an http transport implementation that can be selected by setting {@link #HTTP_TYPE_KEY}. */
    // TODO: we need another name than "http transport"....so confusing with transportClient...
    public void registerHttpTransport(String name, Class<? extends HttpServerTransport> clazz) {
        if (transportClient) {
            throw new IllegalArgumentException("Cannot register http transport " + clazz.getName() + " for transport client");
        }
        httpTransportTypes.registerExtension(name, clazz);
    }

    /** Adds an additional rest action. */
    // TODO: change this further to eliminate the middle man, ie RestController, and just register method and path here
    public void registerRestHandler(Class<? extends RestHandler> clazz) {
        if (transportClient) {
            throw new IllegalArgumentException("Cannot register rest handler " + clazz.getName() + " for transport client");
        }
        if (AbstractCatAction.class.isAssignableFrom(clazz)) {
            catHandlers.registerExtension(clazz.asSubclass(AbstractCatAction.class));
        } else {
            restHandlers.registerExtension(clazz);
        }
    }

    public void registerTaskStatus(String name, Writeable.Reader<? extends Task.Status> reader) {
        namedWriteableRegistry.register(Task.Status.class, name, reader);
    }

    @Override
    protected void configure() {
        bind(NetworkService.class).toInstance(networkService);
        bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry);

        transportServiceTypes.bindType(binder(), settings, TRANSPORT_SERVICE_TYPE_KEY, NETTY_TRANSPORT);
        String defaultTransport = DiscoveryNode.localNode(settings) ? LOCAL_TRANSPORT : NETTY_TRANSPORT;
        transportTypes.bindType(binder(), settings, TRANSPORT_TYPE_KEY, defaultTransport);

        if (transportClient) {
            bind(TransportProxyClient.class).asEagerSingleton();
            bind(TransportClientNodesService.class).asEagerSingleton();
        } else {
            if (HTTP_ENABLED.get(settings)) {
                bind(HttpServer.class).asEagerSingleton();
                httpTransportTypes.bindType(binder(), settings, HTTP_TYPE_SETTING.getKey(), NETTY_TRANSPORT);
            }
            bind(RestController.class).asEagerSingleton();
            catHandlers.bind(binder());
            restHandlers.bind(binder());
        }
    }
}


text:
package org.apache.spark.sql

import scala.collection.mutable

import org.apache.spark.annotation.{DeveloperApi, Experimental, InterfaceStability}
import org.apache.spark.sql.catalyst.FunctionIdentifier
import org.apache.spark.sql.catalyst.analysis.FunctionRegistry
import org.apache.spark.sql.catalyst.analysis.FunctionRegistry.FunctionBuilder
import org.apache.spark.sql.catalyst.expressions.ExpressionInfo
import org.apache.spark.sql.catalyst.parser.ParserInterface
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
import org.apache.spark.sql.catalyst.rules.Rule

/**
 * :: Experimental ::
 * Holder for injection points to the [[SparkSession]]. We make NO guarantee about the stability
 * regarding binary compatibility and source compatibility of methods here.
 *
 * This current provides the following extension points:
 *
 *

 *
Analyzer Rules.

 *
Check Analysis Rules.

 *
Optimizer Rules.

 *
Planning Strategies.

 *
Customized Parser.

 *
(External) Catalog listeners.

 *

 *
 * The extensions can be used by calling withExtension on the [[SparkSession.Builder]], for
 * example:
 * {{{
 *   SparkSession.builder()
 *     .master("...")
 *     .conf("...", true)
 *     .withExtensions { extensions =>
 *       extensions.injectResolutionRule { session =>
 *         ...
 *       }
 *       extensions.injectParser { (session, parser) =>
 *         ...
 *       }
 *     }
 *     .getOrCreate()
 * }}}
 *
 * Note that none of the injected builders should assume that the [[SparkSession]] is fully
 * initialized and should not touch the session's internals (e.g. the SessionState).
 */
@DeveloperApi
@Experimental
@InterfaceStability.Unstable
class SparkSessionExtensions {
  type RuleBuilder = SparkSession => Rule[LogicalPlan]
  type CheckRuleBuilder = SparkSession => LogicalPlan => Unit
  type StrategyBuilder = SparkSession => Strategy
  type ParserBuilder = (SparkSession, ParserInterface) => ParserInterface
  type FunctionDescription = (FunctionIdentifier, ExpressionInfo, FunctionBuilder)

  private[this] val resolutionRuleBuilders = mutable.Buffer.empty[RuleBuilder]

  /**
   * Build the analyzer resolution `Rule`s using the given [[SparkSession]].
   */
  private[sql] def buildResolutionRules(session: SparkSession): Seq[Rule[LogicalPlan]] = {
    resolutionRuleBuilders.map(_.apply(session))
  }

  /**
   * Inject an analyzer resolution `Rule` builder into the [[SparkSession]]. These analyzer
   * rules will be executed as part of the resolution phase of analysis.
   */
  def injectResolutionRule(builder: RuleBuilder): Unit = {
    resolutionRuleBuilders += builder
  }

  private[this] val postHocResolutionRuleBuilders = mutable.Buffer.empty[RuleBuilder]

  /**
   * Build the analyzer post-hoc resolution `Rule`s using the given [[SparkSession]].
   */
  private[sql] def buildPostHocResolutionRules(session: SparkSession): Seq[Rule[LogicalPlan]] = {
    postHocResolutionRuleBuilders.map(_.apply(session))
  }

  /**
   * Inject an analyzer `Rule` builder into the [[SparkSession]]. These analyzer
   * rules will be executed after resolution.
   */
  def injectPostHocResolutionRule(builder: RuleBuilder): Unit = {
    postHocResolutionRuleBuilders += builder
  }

  private[this] val checkRuleBuilders = mutable.Buffer.empty[CheckRuleBuilder]

  /**
   * Build the check analysis `Rule`s using the given [[SparkSession]].
   */
  private[sql] def buildCheckRules(session: SparkSession): Seq[LogicalPlan => Unit] = {
    checkRuleBuilders.map(_.apply(session))
  }

  /**
   * Inject an check analysis `Rule` builder into the [[SparkSession]]. The injected rules will
   * be executed after the analysis phase. A check analysis rule is used to detect problems with a
   * LogicalPlan and should throw an exception when a problem is found.
   */
  def injectCheckRule(builder: CheckRuleBuilder): Unit = {
    checkRuleBuilders += builder
  }

  private[this] val optimizerRules = mutable.Buffer.empty[RuleBuilder]

  private[sql] def buildOptimizerRules(session: SparkSession): Seq[Rule[LogicalPlan]] = {
    optimizerRules.map(_.apply(session))
  }

  /**
   * Inject an optimizer `Rule` builder into the [[SparkSession]]. The injected rules will be
   * executed during the operator optimization batch. An optimizer rule is used to improve the
   * quality of an analyzed logical plan; these rules should never modify the result of the
   * LogicalPlan.
   */
  def injectOptimizerRule(builder: RuleBuilder): Unit = {
    optimizerRules += builder
  }

  private[this] val plannerStrategyBuilders = mutable.Buffer.empty[StrategyBuilder]

  private[sql] def buildPlannerStrategies(session: SparkSession): Seq[Strategy] = {
    plannerStrategyBuilders.map(_.apply(session))
  }

  /**
   * Inject a planner `Strategy` builder into the [[SparkSession]]. The injected strategy will
   * be used to convert a `LogicalPlan` into a executable
   * [[org.apache.spark.sql.execution.SparkPlan]].
   */
  def injectPlannerStrategy(builder: StrategyBuilder): Unit = {
    plannerStrategyBuilders += builder
  }

  private[this] val parserBuilders = mutable.Buffer.empty[ParserBuilder]

  private[sql] def buildParser(
      session: SparkSession,
      initial: ParserInterface): ParserInterface = {
    parserBuilders.foldLeft(initial) { (parser, builder) =>
      builder(session, parser)
    }
  }

  /**
   * Inject a custom parser into the [[SparkSession]]. Note that the builder is passed a session
   * and an initial parser. The latter allows for a user to create a partial parser and to delegate
   * to the underlying parser for completeness. If a user injects more parsers, then the parsers
   * are stacked on top of each other.
   */
  def injectParser(builder: ParserBuilder): Unit = {
    parserBuilders += builder
  }

  private[this] val injectedFunctions = mutable.Buffer.empty[FunctionDescription]

  private[sql] def registerFunctions(functionRegistry: FunctionRegistry) = {
    for ((name, expressionInfo, function) <- injectedFunctions) {
      functionRegistry.registerFunction(name, expressionInfo, function)
    }
    functionRegistry
  }

  /**
  * Injects a custom function into the [[org.apache.spark.sql.catalyst.analysis.FunctionRegistry]]
  * at runtime for all sessions.
  */
  def injectFunction(functionDescription: FunctionDescription): Unit = {
    injectedFunctions += functionDescription
  }
}

redpajama_set_name: RedPajamaGithub


text:
Twig
====

.. toctree::
    :maxdepth: 2

    intro
    templates
    api
    advanced
    internals
    recipes
    coding_standards
    tags/index
    filters/index
    functions/index
    tests/index


text:
go-md2man 1 "January 2015" go-md2man "User Manual"
==================================================

# NAME
  go-md2man - Convert mardown files into manpages

# SYNOPSIS
  go-md2man -in=[/path/to/md/file] -out=[/path/to/output]

# Description
  go-md2man converts standard markdown formatted documents into manpages. It is
  written purely in Go so as to reduce dependencies on 3rd party libs.

  By default, the input is stdin and the output is stdout.

# Example
  Convert the markdown file "go-md2man.1.md" into a manpage.

    go-md2man -in=README.md -out=go-md2man.1.out

# HISTORY
  January 2015, Originally compiled by Brian Goff( cpuguy83@gmail.com )


text:
//
//  PDFAnnotation_SKNExtensions.m
//  SkimNotes
//
//  Created by Christiaan Hofman on 6/15/08.

#import "PDFAnnotation_SKNExtensions.h"
#import "SKNPDFAnnotationNote.h"
#import <objc/objc-runtime.h>
#import <tgmath.h>

NSString *SKNFreeTextString = @"FreeText";
NSString *SKNTextString = @"Text";
NSString *SKNNoteString = @"Note";
NSString *SKNCircleString = @"Circle";
NSString *SKNSquareString = @"Square";
NSString *SKNMarkUpString = @"MarkUp";
NSString *SKNHighlightString = @"Highlight";
NSString *SKNUnderlineString = @"Underline";
NSString *SKNStrikeOutString = @"StrikeOut";
NSString *SKNLineString = @"Line";
NSString *SKNInkString = @"Ink";
NSString *SKNWidgetString = @"Widget";

NSString *SKNPDFAnnotationTypeKey = @"type";
NSString *SKNPDFAnnotationBoundsKey = @"bounds";
NSString *SKNPDFAnnotationPageKey = @"page";
NSString *SKNPDFAnnotationPageIndexKey = @"pageIndex";
NSString *SKNPDFAnnotationContentsKey = @"contents";
NSString *SKNPDFAnnotationStringKey = @"string";
NSString *SKNPDFAnnotationColorKey = @"color";
NSString *SKNPDFAnnotationBorderKey = @"border";
NSString *SKNPDFAnnotationLineWidthKey = @"lineWidth";
NSString *SKNPDFAnnotationBorderStyleKey = @"borderStyle";
NSString *SKNPDFAnnotationDashPatternKey = @"dashPattern";
NSString *SKNPDFAnnotationModificationDateKey = @"modificationDate";
NSString *SKNPDFAnnotationUserNameKey = @"userName";

NSString *SKNPDFAnnotationInteriorColorKey = @"interiorColor";

NSString *SKNPDFAnnotationStartLineStyleKey = @"startLineStyle";
NSString *SKNPDFAnnotationEndLineStyleKey = @"endLineStyle";
NSString *SKNPDFAnnotationStartPointKey = @"startPoint";
NSString *SKNPDFAnnotationEndPointKey = @"endPoint";

NSString *SKNPDFAnnotationFontKey = @"font";
NSString *SKNPDFAnnotationFontColorKey = @"fontColor";
NSString *SKNPDFAnnotationFontNameKey = @"fontName";
NSString *SKNPDFAnnotationFontSizeKey = @"fontSize";
NSString *SKNPDFAnnotationAlignmentKey = @"alignment";
NSString *SKNPDFAnnotationRotationKey = @"rotation";

NSString *SKNPDFAnnotationQuadrilateralPointsKey = @"quadrilateralPoints";

NSString *SKNPDFAnnotationIconTypeKey = @"iconType";

NSString *SKNPDFAnnotationPointListsKey = @"pointLists";

NSString *SKNPDFAnnotationStringValueKey = @"stringValue";
NSString *SKNPDFAnnotationStateKey = @"state";
NSString *SKNPDFAnnotationWidgetTypeKey = @"widgetType";
NSString *SKNPDFAnnotationFieldNameKey = @"fieldName";

static inline NSColor *SKNColorFromArray(NSArray *array) {
    CGFloat c[4] = {0.0, 0.0, 0.0, 1.0};
    if ([array count] > 2) {
        NSUInteger i;
        for (i = 0; i < MAX([array count], 4); i++)
            c[i] = [[array objectAtIndex:i] doubleValue];
    } else if ([array count] > 0) {
        c[0] = c[1] = c[2] = [[array objectAtIndex:0] doubleValue];
        if ([array count] == 2)
            c[3] = [[array objectAtIndex:1] doubleValue];
    }
    return [NSColor colorWithColorSpace:[NSColorSpace sRGBColorSpace] components:c count:4];
}

#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
@interface PDFAnnotation (SKNSierraDeclarations)
- (id)valueForAnnotationKey:(NSString *)key;
@end
#endif

@implementation PDFAnnotation (SKNExtensions)

static NSHashTable *SkimNotes = nil;

static void (*original_dealloc)(id, SEL) = NULL;

static void replacement_dealloc(id self, SEL _cmd) {
    @synchronized([PDFAnnotation self]) {
        [SkimNotes removeObject:self];
    }
    original_dealloc(self, _cmd);
}

+ (void)load {
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
#if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
    SkimNotes = [[NSHashTable alloc] initWithOptions:NSHashTableZeroingWeakMemory | NSHashTableObjectPointerPersonality capacity:0];
#else
    SkimNotes = [[NSHashTable alloc] initWithOptions:NSHashTableWeakMemory | NSHashTableObjectPointerPersonality capacity:0];
#endif
    original_dealloc = (void(*)(id,SEL))method_setImplementation(class_getInstanceMethod(self, @selector(dealloc)), (IMP)replacement_dealloc);
    [pool release];
}

- (id)initSkimNoteWithBounds:(NSRect)bounds {
    self = [self initWithBounds:bounds];
    if (self) {
        [self setShouldPrint:YES];
        [self setSkimNote:YES];
    }
    return self;

}

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    Class stringClass = [NSString class];

    if ([self isMemberOfClass:[PDFAnnotation class]]) {
        // generic, initalize the class for the type in the dictionary
        NSString *type = [dict objectForKey:SKNPDFAnnotationTypeKey];
        Class annotationClass = NULL;
        NSZone *zone = [self zone];

        if ([type isKindOfClass:stringClass] == NO)
            annotationClass = Nil;
        else if ([type isEqualToString:SKNNoteString] || [type isEqualToString:SKNTextString])
            annotationClass = [SKNPDFAnnotationNote class];
        else if ([type isEqualToString:SKNFreeTextString])
            annotationClass = [PDFAnnotationFreeText class];
        else if ([type isEqualToString:SKNCircleString])
            annotationClass = [PDFAnnotationCircle class];
        else if ([type isEqualToString:SKNSquareString])
            annotationClass = [PDFAnnotationSquare class];
        else if ([type isEqualToString:SKNHighlightString] || [type isEqualToString:SKNMarkUpString] || [type isEqualToString:SKNUnderlineString] || [type isEqualToString:SKNStrikeOutString])
            annotationClass = [PDFAnnotationMarkup class];
        else if ([type isEqualToString:SKNLineString])
            annotationClass = [PDFAnnotationLine class];
        else if ([type isEqualToString:SKNInkString])
            annotationClass = [PDFAnnotationInk class];

        [[self initWithBounds:NSZeroRect] release];
        self = [[annotationClass allocWithZone:zone] initSkimNoteWithProperties:dict];

    } else {
        // called from the initialization of a subclass
        NSString *boundsString = [dict objectForKey:SKNPDFAnnotationBoundsKey];
        NSRect bounds = [boundsString isKindOfClass:stringClass] ? NSRectFromString(boundsString) : NSZeroRect;
        self = [self initSkimNoteWithBounds:bounds];
        if (self) {
            Class colorClass = [NSColor class];
            Class arrayClass = [NSArray class];
            Class dateClass = [NSDate class];
            NSString *contents = [dict objectForKey:SKNPDFAnnotationContentsKey];
            NSColor *color = [dict objectForKey:SKNPDFAnnotationColorKey];
            NSDate *modificationDate = [dict objectForKey:SKNPDFAnnotationModificationDateKey];
            NSString *userName = [dict objectForKey:SKNPDFAnnotationUserNameKey];
            NSNumber *lineWidth = [dict objectForKey:SKNPDFAnnotationLineWidthKey];
            NSNumber *borderStyle = [dict objectForKey:SKNPDFAnnotationBorderStyleKey];
            NSArray *dashPattern = [dict objectForKey:SKNPDFAnnotationDashPatternKey];

            if ([contents isKindOfClass:stringClass])
                [self setString:contents];
            if ([color isKindOfClass:colorClass])
                [self setColor:color];
            else if ([color isKindOfClass:arrayClass])
                [self setColor:SKNColorFromArray((NSArray *)color)];
            if ([modificationDate isKindOfClass:dateClass] && [self respondsToSelector:@selector(setModificationDate:)])
                [self setModificationDate:modificationDate];
            if ([userName isKindOfClass:stringClass] && [self respondsToSelector:@selector(setUserName:)])
                [self setUserName:userName];
            if (lineWidth || borderStyle || dashPattern) {
                if ([self border] == nil)
                    [self setBorder:[[[PDFBorder alloc] init] autorelease]];
                if ([lineWidth respondsToSelector:@selector(floatValue)])
                    [[self border] setLineWidth:[lineWidth floatValue]];
                if ([dashPattern isKindOfClass:arrayClass])
                    [[self border] setDashPattern:dashPattern];
                if ([borderStyle respondsToSelector:@selector(integerValue)])
                    [[self border] setStyle:[borderStyle integerValue]];
            } else if ([self border]) {
                [self setBorder:nil];
                // On 10.12 a border with lineWith 1 is inserted, so set its lineWidth to 0
                [[self border] setLineWidth:0.0];
            }
        }

    }
    return self;
}

- (NSMutableDictionary *)genericSkimNoteProperties{
    PDFPage *page = [self page];
    NSUInteger pageIndex = page ? [[page document] indexForPage:page] : NSNotFound;
    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:5];
    [dict setValue:[self type] forKey:SKNPDFAnnotationTypeKey];
    [dict setValue:[self string] forKey:SKNPDFAnnotationContentsKey];
    [dict setValue:[self color] forKey:SKNPDFAnnotationColorKey];
    if ([self respondsToSelector:@selector(modificationDate)])
        [dict setValue:[self modificationDate] forKey:SKNPDFAnnotationModificationDateKey];
    if ([self respondsToSelector:@selector(userName)])
        [dict setValue:[self userName] forKey:SKNPDFAnnotationUserNameKey];
    [dict setValue:NSStringFromRect([self bounds]) forKey:SKNPDFAnnotationBoundsKey];
    [dict setValue:[NSNumber numberWithUnsignedInteger:pageIndex == NSNotFound ? 0 : pageIndex] forKey:SKNPDFAnnotationPageIndexKey];
    if ([self border] && [[self border] lineWidth] > 0.0) {
        [dict setValue:[NSNumber numberWithFloat:[[self border] lineWidth]] forKey:SKNPDFAnnotationLineWidthKey];
        [dict setValue:[NSNumber numberWithInteger:[[self border] style]] forKey:SKNPDFAnnotationBorderStyleKey];
        [dict setValue:[[self border] dashPattern] forKey:SKNPDFAnnotationDashPatternKey];
    }
    return dict;
}

static inline PDFBorderStyle SKNPDFBorderStyleFromAnnotationValue(id value) {
    if ([value isKindOfClass:[NSString class]] == NO)
        return kPDFBorderStyleSolid;
    if ([value isEqualToString:@"/S"])
        return kPDFBorderStyleSolid;
    else if ([value isEqualToString:@"/D"])
        return kPDFBorderStyleDashed;
    else if ([value isEqualToString:@"/B"])
        return kPDFBorderStyleBeveled;
    else if ([value isEqualToString:@"/I"])
        return kPDFBorderStyleInset;
    else if ([value isEqualToString:@"/U"])
        return kPDFBorderStyleUnderline;
    else
        return kPDFBorderStyleSolid;
}

static inline NSColor *SKNColorFromAnnotationValue(id value) {
    if ([value isKindOfClass:[NSColor class]])
        return value;
    if ([value isKindOfClass:[NSArray class]] == NO || [value count] == 0)
        return nil;
    if ([value count] < 3)
        return [NSColor colorWithDeviceWhite:[[value objectAtIndex:0] floatValue] alpha:[value count] > 1 ? [[value objectAtIndex:1] floatValue] : 1.0];
    return [NSColor colorWithDeviceRed:[[value objectAtIndex:0] floatValue] green:[[value objectAtIndex:1] floatValue] blue:[[value objectAtIndex:2] floatValue] alpha:[value count] > 3 ? [[value objectAtIndex:3] floatValue] : 1.0];
}

static inline PDFTextAnnotationIconType SKNIconTypeFromAnnotationValue(id value) {
    if ([value isKindOfClass:[NSString class]] == NO)
        return kPDFTextAnnotationIconNote;
    if ([value isEqualToString:@"/Comment"])
        return kPDFTextAnnotationIconComment;
    else if ([value isEqualToString:@"/Key"])
        return kPDFTextAnnotationIconKey;
    else if ([value isEqualToString:@"/Note"])
        return kPDFTextAnnotationIconNote;
    else if ([value isEqualToString:@"/NewParagraph"])
        return kPDFTextAnnotationIconNewParagraph;
    else if ([value isEqualToString:@"/Paragraph"])
        return kPDFTextAnnotationIconParagraph;
    else if ([value isEqualToString:@"/Insert"])
        return kPDFTextAnnotationIconInsert;
    else
        return kPDFTextAnnotationIconNote;
}

static inline PDFLineStyle SKNPDFLineStyleFromAnnotationValue(id value) {
    if ([value isKindOfClass:[NSString class]] == NO)
        return kPDFLineStyleNone;
    if ([value isEqualToString:@"/None"])
        return kPDFLineStyleNone;
    else if ([value isEqualToString:@"/Square"])
        return kPDFLineStyleSquare;
    else if ([value isEqualToString:@"/Circle"])
        return kPDFLineStyleCircle;
    else if ([value isEqualToString:@"/Diamond"])
        return kPDFLineStyleDiamond;
    else if ([value isEqualToString:@"/OpenArrow"])
        return kPDFLineStyleOpenArrow;
    else if ([value isEqualToString:@"/ClosedArrow"])
        return kPDFLineStyleClosedArrow;
    else
        return kPDFLineStyleNone;
}

- (NSDictionary *)SkimNoteProperties{
    NSMutableDictionary *dict = [self genericSkimNoteProperties];

    if ([self respondsToSelector:@selector(valueForAnnotationKey:)]) {
        NSRect bounds = [self bounds];
        id value = nil;
        Class arrayClass = [NSArray class];
        Class dictClass = [NSDictionary class];
        Class dateClass = [NSDate class];
        Class stringClass = [NSString class];

        if ([dict objectForKey:SKNPDFAnnotationLineWidthKey] == nil) {
            if ((value = [self valueForAnnotationKey:@"/BS"])) {
                if ([value isKindOfClass:dictClass]) {
                    [dict setValue:[NSNumber numberWithFloat:[[value objectForKey:@"/W"] floatValue]] forKey:SKNPDFAnnotationLineWidthKey];
                    [dict setValue:[NSNumber numberWithInteger:SKNPDFBorderStyleFromAnnotationValue([value objectForKey:@"/S"])] forKey:SKNPDFAnnotationBorderStyleKey];
                    [dict setValue:[value objectForKey:@"/D"] forKey:SKNPDFAnnotationDashPatternKey];
                }
            } else if ((value = [self valueForAnnotationKey:@"/Border"])) {
                if ([value isKindOfClass:arrayClass] && [value count] >= 3) {
                    [dict setValue:[NSNumber numberWithFloat:[[value objectAtIndex:2] floatValue]] forKey:SKNPDFAnnotationLineWidthKey];
                    if ([value count] == 3) {
                        [dict setValue:[NSNumber numberWithInteger:kPDFBorderStyleSolid] forKey:SKNPDFAnnotationBorderStyleKey];
                    } else {
                        [dict setValue:[NSNumber numberWithInteger:kPDFBorderStyleDashed] forKey:SKNPDFAnnotationBorderStyleKey];
                        [dict setValue:[value objectAtIndex:3] forKey:SKNPDFAnnotationDashPatternKey];
                    }
                }
            }
        }

        if ([dict objectForKey:SKNPDFAnnotationModificationDateKey] == nil && (value = [self valueForAnnotationKey:@"/M"])) {
            NSDate *date = nil;
            if ([value isKindOfClass:stringClass]) {
                NSMutableString *string = [value mutableCopy];
                if ([string hasPrefix:@"D:"])
                    [string deleteCharactersInRange:NSMakeRange(0, 2)];
                [string replaceOccurrencesOfString:@"'" withString:@"" options:0 range:NSMakeRange(0, [string length])];
                if ([string hasSuffix:@"Z0000"])
                    [string replaceCharactersInRange:NSMakeRange([string length] - 5, 1) withString:@"+"];
                else if ([string length] == 14)
                    [string appendString:@"+0000"];
                NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
                [formatter setDateFormat:@"yyyyMMddHHmmssZZ"];
                value = [formatter dateFromString:string];
                [formatter release];
                [string release];
            }
            if ([value isKindOfClass:dateClass])
                [dict setValue:date forKey:SKNPDFAnnotationModificationDateKey];
        }

        if ([dict objectForKey:SKNPDFAnnotationUserNameKey] == nil && (value = [self valueForAnnotationKey:@"/Contents"]))
            [dict setValue:value forKey:SKNPDFAnnotationContentsKey];

        if ([dict objectForKey:SKNPDFAnnotationUserNameKey] == nil && (value = [self valueForAnnotationKey:@"/T"]))
            [dict setValue:value forKey:SKNPDFAnnotationUserNameKey];

        if ([dict objectForKey:SKNPDFAnnotationColorKey] == nil && (value = [self valueForAnnotationKey:@"/C"]))
            [dict setValue:SKNColorFromAnnotationValue(value) forKey:SKNPDFAnnotationColorKey];

        if ([dict objectForKey:SKNPDFAnnotationInteriorColorKey] == nil && (value = [self valueForAnnotationKey:@"/IC"]))
            [dict setValue:SKNColorFromAnnotationValue(value) forKey:SKNPDFAnnotationInteriorColorKey];

        if ((value = [self valueForAnnotationKey:@"/Name"]))
            [dict setValue:[NSNumber numberWithInteger:SKNIconTypeFromAnnotationValue(value)] forKey:SKNPDFAnnotationIconTypeKey];

        if ((value = [self valueForAnnotationKey:@"/LE"])) {
            if ([value isKindOfClass:arrayClass] && [value count] == 2) {
                [dict setValue:[NSNumber numberWithInteger:SKNPDFLineStyleFromAnnotationValue([value objectAtIndex:0])] forKey:SKNPDFAnnotationStartLineStyleKey];
                [dict setValue:[NSNumber numberWithInteger:SKNPDFLineStyleFromAnnotationValue([value objectAtIndex:1])] forKey:SKNPDFAnnotationEndLineStyleKey];
            }
        }

        if ((value = [self valueForAnnotationKey:@"/L"])) {
            if ([value isKindOfClass:arrayClass] && [value count] == 4) {
                NSPoint p = NSMakePoint([[value objectAtIndex:0] floatValue] - NSMinX(bounds), [[value objectAtIndex:1] floatValue] - NSMinY(bounds));
                [dict setValue:NSStringFromPoint(p) forKey:SKNPDFAnnotationStartPointKey];
                p = NSMakePoint([[value objectAtIndex:2] floatValue] - NSMinX(bounds), [[value objectAtIndex:3] floatValue] - NSMinY(bounds));
                [dict setValue:NSStringFromPoint(p) forKey:SKNPDFAnnotationEndPointKey];
            }
        }

        if ((value = [self valueForAnnotationKey:@"/QuadPoints"])) {
            if ([value isKindOfClass:arrayClass] && [value count] % 8 == 0) {
                NSMutableArray *quadPoints = [NSMutableArray array];
                NSUInteger i, iMax = [value count];
                for (i = 0; i < iMax; i += 2) {
                    NSPoint p = NSMakePoint([[value objectAtIndex:i] floatValue] - NSMinX(bounds), [[value objectAtIndex:i + 1] floatValue] - NSMinY(bounds));
                    [quadPoints addObject:NSStringFromPoint(p)];
                }
                [dict setValue:quadPoints forKey:SKNPDFAnnotationQuadrilateralPointsKey];
            }
        }

        if ((value = [self valueForAnnotationKey:@"/InkList"])) {
            if ([value isKindOfClass:arrayClass]) {
                NSMutableArray *pointLists = [NSMutableArray array];
                NSUInteger i, iMax = [value count];
                for (i = 0; i < iMax; i++) {
                    NSArray *array = [value objectAtIndex:i];
                    if ([array isKindOfClass:arrayClass] && [array count] % 2 == 0) {
                        NSMutableArray *points = [NSMutableArray array];
                        NSUInteger j, jMax = [array count];
                        for (j = 0; j < jMax; j += 2) {
                            NSPoint p = NSMakePoint([[array objectAtIndex:j] floatValue] - NSMinX(bounds), [[array objectAtIndex:j + 1] floatValue] - NSMinY(bounds));
                            [points addObject:NSStringFromPoint(p)];
                        }
                        [pointLists addObject:points];
                    }
                }
                [dict setValue:pointLists forKey:SKNPDFAnnotationPointListsKey];
            }
        }

        if ((value = [self valueForAnnotationKey:@"/Q"])) {
            NSInteger align = [value integerValue];
            [dict setValue:[NSNumber numberWithInteger:align == 1 ? NSCenterTextAlignment : align == 2 ? NSRightTextAlignment : NSLeftTextAlignment] forKey:SKNPDFAnnotationAlignmentKey];
        }

        if ((value = [self valueForAnnotationKey:@"/DA"])) {
            NSScanner *scanner = [[NSScanner alloc] initWithString:value];
            NSString *fontName;
            double fontSize;
            if ([scanner scanUpToString:@"Tf" intoString:NULL] && [scanner isAtEnd] == NO) {
                NSUInteger location = [scanner scanLocation];
                NSRange r = [value rangeOfString:@"/" options:NSBackwardsSearch range:NSMakeRange(0, location)];
                if (r.location != NSNotFound) {
                    [scanner setScanLocation:NSMaxRange(r)];
                    if ([scanner scanUpToCharactersFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet] intoString:&fontName] &&
                        [scanner scanDouble:&fontSize] &&
                        [scanner scanString:@"Tf" intoString:NULL] &&
                        [scanner scanLocation] == location + 2) {
                        NSFont *font = [NSFont fontWithName:fontName size:fontSize];
                        if (font)
                            [dict setObject:font forKey:SKNPDFAnnotationFontKey];
                    }
                }
            }
            [scanner release];
        }
    }

    return dict;
}

- (BOOL)isSkimNote {
    BOOL isSkimNote;
    @synchronized([PDFAnnotation self]) {
        isSkimNote = [SkimNotes containsObject:self];
    }
    return isSkimNote;
}

- (void)setSkimNote:(BOOL)flag {
    @synchronized([PDFAnnotation self]) {
        if (flag) [SkimNotes addObject:self];
        else [SkimNotes removeObject:self];
    }
}

- (NSString *)string {
    return [self contents];
}

- (void)setString:(NSString *)newString {
    [self setContents:newString];
}

@end

#pragma mark -

@implementation PDFAnnotationCircle (SKNExtensions)

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        Class colorClass = [NSColor class];
        Class arrayClass = [NSArray class];
        NSColor *interiorColor = [dict objectForKey:SKNPDFAnnotationInteriorColorKey];
        if ([interiorColor isKindOfClass:colorClass])
            [self setInteriorColor:interiorColor];
        else if ([interiorColor isKindOfClass:arrayClass])
            [self setInteriorColor:SKNColorFromArray((NSArray *)interiorColor)];
    }
    return self;
}

- (NSDictionary *)SkimNoteProperties{
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[self interiorColor] forKey:SKNPDFAnnotationInteriorColorKey];
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationSquare (SKNExtensions)

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        Class colorClass = [NSColor class];
        Class arrayClass = [NSArray class];
        NSColor *interiorColor = [dict objectForKey:SKNPDFAnnotationInteriorColorKey];
        if ([interiorColor isKindOfClass:colorClass])
            [self setInteriorColor:interiorColor];
        else if ([interiorColor isKindOfClass:arrayClass])
            [self setInteriorColor:SKNColorFromArray((NSArray *)interiorColor)];
    }
    return self;
}

- (NSDictionary *)SkimNoteProperties{
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[self interiorColor] forKey:SKNPDFAnnotationInteriorColorKey];
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationLine (SKNExtensions)

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        Class stringClass = [NSString class];
        Class colorClass = [NSColor class];
        Class arrayClass = [NSArray class];
        NSString *startPoint = [dict objectForKey:SKNPDFAnnotationStartPointKey];
        NSString *endPoint = [dict objectForKey:SKNPDFAnnotationEndPointKey];
        NSNumber *startLineStyle = [dict objectForKey:SKNPDFAnnotationStartLineStyleKey];
        NSNumber *endLineStyle = [dict objectForKey:SKNPDFAnnotationEndLineStyleKey];
        NSColor *interiorColor = [dict objectForKey:SKNPDFAnnotationInteriorColorKey];
        if ([startPoint isKindOfClass:stringClass])
            [self setStartPoint:NSPointFromString(startPoint)];
        if ([endPoint isKindOfClass:stringClass])
            [self setEndPoint:NSPointFromString(endPoint)];
        if ([startLineStyle respondsToSelector:@selector(integerValue)])
            [self setStartLineStyle:[startLineStyle integerValue]];
        if ([endLineStyle respondsToSelector:@selector(integerValue)])
            [self setEndLineStyle:[endLineStyle integerValue]];
        if ([self respondsToSelector:@selector(setInteriorColor:)]) {
            if ([interiorColor isKindOfClass:colorClass] && [self respondsToSelector:@selector(setInteriorColor:)])
                [self setInteriorColor:interiorColor];
            else if ([interiorColor isKindOfClass:arrayClass])
                [self setInteriorColor:SKNColorFromArray((NSArray *)interiorColor)];
        }
    }
    return self;
}

- (NSDictionary *)SkimNoteProperties {
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[NSNumber numberWithInteger:[self startLineStyle]] forKey:SKNPDFAnnotationStartLineStyleKey];
    [dict setValue:[NSNumber numberWithInteger:[self endLineStyle]] forKey:SKNPDFAnnotationEndLineStyleKey];
    [dict setValue:NSStringFromPoint([self startPoint]) forKey:SKNPDFAnnotationStartPointKey];
    [dict setValue:NSStringFromPoint([self endPoint]) forKey:SKNPDFAnnotationEndPointKey];
    if ([self respondsToSelector:@selector(interiorColor)])
        [dict setValue:[self interiorColor] forKey:SKNPDFAnnotationInteriorColorKey];
    return dict;
}

@end

#pragma mark -

@interface PDFAnnotationFreeText (SKNPDFAnnotationFreeTextPrivateDeclarations)
- (int)rotation;
- (void)setRotation:(int)rotation;
- (NSColor *)fontColor;
- (void)setFontColor:(NSColor *)color;
@end

@implementation PDFAnnotationFreeText (SKNExtensions)

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        Class fontClass = [NSFont class];
        Class colorClass = [NSColor class];
        Class arrayClass = [NSArray class];
        NSFont *font = [dict objectForKey:SKNPDFAnnotationFontKey];
        NSColor *fontColor = [dict objectForKey:SKNPDFAnnotationFontColorKey];
        NSNumber *alignment = [dict objectForKey:SKNPDFAnnotationAlignmentKey];
        NSNumber *rotation = [dict objectForKey:SKNPDFAnnotationRotationKey];
        if (font == nil) {
            NSString *fontName = [dict objectForKey:SKNPDFAnnotationFontNameKey];
            NSNumber *fontSize = [dict objectForKey:SKNPDFAnnotationFontSizeKey];
            if ([fontName isKindOfClass:[NSString class]])
                font = [NSFont fontWithName:fontName size:[fontSize respondsToSelector:@selector(doubleValue)] ? [fontSize doubleValue] : 0.0];
        }
        if ([font isKindOfClass:fontClass])
            [self setFont:font];
        if ([self respondsToSelector:@selector(setFontColor:)]) {
            if ([fontColor isKindOfClass:colorClass])
                [self setFontColor:fontColor];
            else if ([fontColor isKindOfClass:arrayClass])
                [self setFontColor:SKNColorFromArray((NSArray *)fontColor)];
        }
        if ([alignment respondsToSelector:@selector(integerValue)])
            [self setAlignment:[alignment integerValue]];
        if ([rotation respondsToSelector:@selector(integerValue)] && [self respondsToSelector:@selector(setRotation:)])
            [self setRotation:[rotation intValue]];
    }
    return self;
}

- (NSDictionary *)SkimNoteProperties{
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[self font] forKey:SKNPDFAnnotationFontKey];
    if ([self respondsToSelector:@selector(fontColor)] && [[self fontColor] isEqual:[NSColor colorWithCalibratedWhite:0.0 alpha:0.0]] == NO)
        [dict setValue:[self fontColor] forKey:SKNPDFAnnotationFontColorKey];
    [dict setValue:[NSNumber numberWithInteger:[self alignment]] forKey:SKNPDFAnnotationAlignmentKey];
    if ([self respondsToSelector:@selector(rotation)])
        [dict setValue:[NSNumber numberWithInteger:[self rotation]] forKey:SKNPDFAnnotationRotationKey];
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationMarkup (SKNExtensions)
/*
 http://www.cocoabuilder.com/archive/message/cocoa/2007/2/16/178891
 The docs are wrong (as is Adobe's spec).  The ordering on the rotated page is:
 --------
 | 0  1 |
 | 2  3 |
 --------
 */

static inline void swapPoints(NSPoint p[4], NSUInteger i, NSUInteger j) {
    NSPoint tmp = p[i];
    p[i] = p[j];
    p[j] = tmp;
}

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        Class stringClass = [NSString class];
        NSString *type = [dict objectForKey:SKNPDFAnnotationTypeKey];
        if ([type isKindOfClass:stringClass]) {
            NSInteger markupType = kPDFMarkupTypeHighlight;
            if ([type isEqualToString:SKNUnderlineString])
                markupType = kPDFMarkupTypeUnderline;
            else if ([type isEqualToString:SKNStrikeOutString])
                markupType = kPDFMarkupTypeStrikeOut;
            if (markupType != [self markupType]) {
                [self setMarkupType:markupType];
                if ([dict objectForKey:SKNPDFAnnotationColorKey] == nil && [[self class] respondsToSelector:@selector(defaultSkimNoteColorForMarkupType:)]) {
                    NSColor *color = [[self class] defaultSkimNoteColorForMarkupType:markupType];
                    if (color)
                        [self setColor:color];
                }
            }
        }

        Class arrayClass = [NSArray class];
        NSArray *pointStrings = [dict objectForKey:SKNPDFAnnotationQuadrilateralPointsKey];
        if ([pointStrings isKindOfClass:arrayClass]) {
            // fix the order, as we have done it wrong for a long time
            NSUInteger i, iMax = [pointStrings count] / 4;
            NSMutableArray *quadPoints = [[NSMutableArray alloc] initWithCapacity:4 * iMax];
            for (i = 0; i < iMax; i++) {
                NSPoint p[4];
                NSUInteger j;
                for (j = 0; j < 4; j++)
                    p[j] = NSPointFromString([pointStrings objectAtIndex:4 * i + j]);
                // p[0]-p[1] should be in the same direction as p[2]-p[3]
                if ((p[1].x - p[0].x) * (p[3].x - p[2].x) + (p[1].y - p[0].y) * (p[3].y - p[2].y) < 0.0) {
                    swapPoints(p, 2, 3);
                }
                // p[0], p[1], p[2] should be ordered clockwise
                if ((p[1].y - p[0].y) * (p[2].x - p[0].x) - (p[1].x - p[0].x) * (p[2].y - p[0].y) < 0.0) {
                    swapPoints(p, 0, 2);
                    swapPoints(p, 1, 3);
                }
                for (j = 0; j < 4; j++) {
                    NSValue *value = [[NSValue alloc] initWithBytes:&p[j] objCType:@encode(NSPoint)];
                    [quadPoints addObject:value];
                    [value release];
                }
            }
            [self setQuadrilateralPoints:quadPoints];
            [quadPoints release];
        }

    }
    return self;
}

- (NSDictionary *)SkimNoteProperties {
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    NSArray *quadPoints = [self quadrilateralPoints];
    if (quadPoints) {
        NSUInteger i, iMax = [quadPoints count];
        NSMutableArray *quadPointStrings = [[NSMutableArray alloc] initWithCapacity:iMax];
        for (i = 0; i < iMax; i++)
            [quadPointStrings addObject:NSStringFromPoint([[quadPoints objectAtIndex:i] pointValue])];
        [dict setValue:quadPointStrings forKey:SKNPDFAnnotationQuadrilateralPointsKey];
        [quadPointStrings release];
    }
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationText (SKNExtensions)

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        NSNumber *iconType = [dict objectForKey:SKNPDFAnnotationIconTypeKey];
        if ([iconType respondsToSelector:@selector(integerValue)])
            [self setIconType:[iconType integerValue]];
    }
    return self;
}

- (NSDictionary *)SkimNoteProperties{
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[NSNumber numberWithInteger:[self iconType]] forKey:SKNPDFAnnotationIconTypeKey];
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationInk (SKNExtensions)

+ (void)addPoint:(NSPoint)point toSkimNotesPath:(NSBezierPath *)path {
    NSUInteger count = [path elementCount];

    if (count == 0) {

        [path moveToPoint:point];

    } else if (count == 1) {

        [path lineToPoint:point];

    } else {

        NSBezierPathElement elt;
        NSPoint points[3];
        NSPoint diff, controlPoint, point0, point1;
        CGFloat t, dInv, d0, d1;

        elt = [path elementAtIndex:count - 2 associatedPoints:points];
        point0 = elt == NSCurveToBezierPathElement ? points[2] : points[0];

        elt = [path elementAtIndex:count - 1 associatedPoints:points];
        point1 = elt == NSCurveToBezierPathElement ? points[2] : points[0];

        diff.x = point.x - point0.x;
        diff.y = point.y - point0.y;

        d0 = fabs((point1.x - point0.x) * diff.x + (point1.y - point0.y) * diff.y);
        d1 = fabs((point.x - point1.x) * diff.x + (point.y - point1.y) * diff.y);
        dInv = d0 + d1 > 0.0 ? 1.0 / (3.0 * (d0 + d1)) : 0.0;

        t = d0 * dInv;
        controlPoint.x = point1.x - t * diff.x;
        controlPoint.y = point1.y - t * diff.y;

        if (elt == NSCurveToBezierPathElement) {
            points[1] = controlPoint;
            [path setAssociatedPoints:points atIndex:count - 1];
        } else if (count == 2) {
            [path removeAllPoints];
            [path moveToPoint:point0];
            [path curveToPoint:point1 controlPoint1:point0 controlPoint2:controlPoint];
        }

        t = d1 * dInv;
        controlPoint.x = point1.x + t * diff.x;
        controlPoint.y = point1.y + t * diff.y;

        [path curveToPoint:point controlPoint1:controlPoint controlPoint2:point];

    }
}

- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
    self = [super initSkimNoteWithProperties:dict];
    if (self) {
        Class arrayClass = [NSArray class];
        Class stringClass = [NSString class];
        NSArray *pointLists = [dict objectForKey:SKNPDFAnnotationPointListsKey];
        if ([pointLists isKindOfClass:arrayClass]) {
            Class selfClass = [self class];
            NSUInteger i, iMax = [pointLists count];
            for (i = 0; i < iMax; i++) {
                NSArray *pointStrings = [pointLists objectAtIndex:i];
                if ([pointStrings isKindOfClass:arrayClass]) {
                    NSUInteger j, jMax = [pointStrings count];
                    NSBezierPath *path = [NSBezierPath bezierPath];
                    for (j = 0; j < jMax; j++) {
                        NSString *pointString = [pointStrings objectAtIndex:j];
                        if ([pointString isKindOfClass:stringClass])
                            [selfClass addPoint:NSPointFromString(pointString) toSkimNotesPath:path];
                    }
                    [self addBezierPath:path];
                }
            }
        }
    }
    return self;
}

- (NSDictionary *)SkimNoteProperties{
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    NSArray *paths = [self paths];
    if (paths) {
        NSUInteger i, iMax = [paths count];
        NSMutableArray *pointLists = [[NSMutableArray alloc] initWithCapacity:iMax];
        for (i = 0; i < iMax; i++) {
            NSBezierPath *path = [paths objectAtIndex:i];
            NSUInteger j, jMax = [path elementCount];
            NSMutableArray *pointStrings = [[NSMutableArray alloc] initWithCapacity:jMax];
            for (j = 0; j < jMax; j++) {
                NSPoint points[3];
                NSBezierPathElement element = [path elementAtIndex:j associatedPoints:points];
                NSPoint point = element == NSCurveToBezierPathElement ? points[2] : points[0];
                [pointStrings addObject:NSStringFromPoint(point)];
            }
            [pointLists addObject:pointStrings];
            [pointStrings release];
        }
        [dict setValue:pointLists forKey:SKNPDFAnnotationPointListsKey];
        [pointLists release];
    }
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationTextWidget (SKNExtensions)

- (NSDictionary *)SkimNoteProperties {
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[self type] forKey:SKNPDFAnnotationTypeKey];
    [dict setValue:NSStringFromRect([self bounds]) forKey:SKNPDFAnnotationBoundsKey];
    [dict setValue:[NSNumber numberWithInteger:kSKNPDFWidgetTypeText] forKey:SKNPDFAnnotationWidgetTypeKey];
    [dict setValue:[self fieldName] forKey:SKNPDFAnnotationFieldNameKey];
    [dict setValue:[self stringValue] forKey:SKNPDFAnnotationStringValueKey];
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationButtonWidget (SKNExtensions)

- (NSDictionary *)SkimNoteProperties {
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[self type] forKey:SKNPDFAnnotationTypeKey];
    [dict setValue:NSStringFromRect([self bounds]) forKey:SKNPDFAnnotationBoundsKey];
    [dict setValue:[NSNumber numberWithInteger:kSKNPDFWidgetTypeButton] forKey:SKNPDFAnnotationWidgetTypeKey];
    [dict setValue:[self fieldName] forKey:SKNPDFAnnotationFieldNameKey];
    [dict setValue:[NSNumber numberWithInteger:[self state]] forKey:SKNPDFAnnotationStateKey];
    return dict;
}

@end

#pragma mark -

@implementation PDFAnnotationChoiceWidget (SKNExtensions)

- (NSDictionary *)SkimNoteProperties {
    NSMutableDictionary *dict = [self genericSkimNoteProperties];
    [dict setValue:[self type] forKey:SKNPDFAnnotationTypeKey];
    [dict setValue:NSStringFromRect([self bounds]) forKey:SKNPDFAnnotationBoundsKey];
    [dict setValue:[NSNumber numberWithInteger:kSKNPDFWidgetTypeChoice] forKey:SKNPDFAnnotationWidgetTypeKey];
    [dict setValue:[self fieldName] forKey:SKNPDFAnnotationFieldNameKey];
    [dict setValue:[self stringValue] forKey:SKNPDFAnnotationStringValueKey];
    return dict;
}

@end

#pragma mark -

#if __LP64__ && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5

// the implementation of -[PDFBorder dashPattern] is badly broken on 10.4 and 10.5 in the 64-bit binary, probably due to the wrong type for _pdfPriv.dashCount or _pdfPriv.dashPattern

@implementation PDFBorder (SKNExtensions)

static NSArray *replacement_dashPattern(id self, SEL _cmd) {
    NSMutableArray *pattern = [NSMutableArray array];
    @try {
        id vars = nil;
        if (NULL != object_getInstanceVariable(vars, "_pdfPriv", (void **)&vars)) {
            Ivar countIvar = object_getInstanceVariable(vars, "dashCount", NULL);
            if (countIvar != NULL) {
                NSUInteger i, count = *(unsigned int *)((void *)vars + ivar_getOffset(countIvar));
                Ivar patternIvar = object_getInstanceVariable(vars, "dashPattern", NULL);
                if (patternIvar != NULL) {
                    float *dashPattern = *(float **)((void *)vars + ivar_getOffset(patternIvar));
                    for (i = 0; i < count; i++)
                        [pattern addObject:[NSNumber numberWithFloat:dashPattern[i]]];
                }
            }
        }
    }
    @catch (id e) {}
    return pattern;
}

+ (void)load {
    if (class_getInstanceVariable(self, "_pdfPriv")) {
        Class cls = NSClassFromString(@"PDFBorderPrivateVars");
        if (cls) {
            Ivar dashCountIvar = class_getInstanceVariable(cls, "dashCount");
            Ivar dashPatternIvar = class_getInstanceVariable(cls, "dashPattern");
            if (dashCountIvar && 0 == strcmp(ivar_getTypeEncoding(dashCountIvar), @encode(unsigned int)) && dashPatternIvar && 0 == strcmp(ivar_getTypeEncoding(dashPatternIvar), @encode(float *)))
                class_replaceMethod(self, @selector(dashPattern), (IMP)replacement_dashPattern, "@@:");
        }
    }
}

@end

#endif


text:
package org.slc.sli.api.validation.impl;

import java.net.URI;

import org.apache.commons.validator.routines.UrlValidator;
import org.springframework.stereotype.Component;

import org.slc.sli.api.validation.URLValidator;

/**
 * A simple url validator using apache-common url validator
 * @author srupasinghe
 *
 */
@Component
public class SimpleURLValidator implements URLValidator {

    @Override
    public boolean validate(URI url) {
        String[] schemes = {"http", "https"};
        UrlValidator validator = new UrlValidator(schemes);

        return validator.isValid(url.toString());
    }
}


text:
// TypeScript Version: 2.0

/**
* Tests if an object has a specified property.
*
* @param value - value to test
* @param property - property to test
* @returns boolean indicating if an object has a specified property
*
* @example
* var beep = {
*     'boop': true
* };
*
* var bool = hasOwnProp( beep, 'boop' );
* // returns true
*
* @example
* var beep = {
*     'boop': true
* };
*
* var bool = hasOwnProp( beep, 'bap' );
* // returns false
*/
declare function hasOwnProp( value: any, property: any ): boolean;

// EXPORTS //

export = hasOwnProp;


text:
package hudson.plugins.selenium;

import jenkins.security.MasterToSlaveCallable;

class HubParamsCallable extends MasterToSlaveCallable<HubParams, Throwable> {

	/**
	 *
	 */
	private static final long serialVersionUID = -4136171068376050199L;

	public HubParams call() throws Throwable {
		if (HubHolder.getHub() == null) {
			return new HubParams();
		}
		return new HubParams(HubHolder.getHub().getHost(), HubHolder.getHub().getPort(), true);
	}
}


text:
package com.lzc.jiaowaimai.activity.sqlite;

import java.io.ByteArrayOutputStream;

import com.lzc.jiaowaimai.R;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

/** ±¾µØÊý¾Ý±í */
public class LocalSQLite extends SQLiteOpenHelper
{
	public static final int VERSION = 24;
	public static final String BD_NAME = "jiaowaimai.db";

	private Context mContext;

	public LocalSQLite(Context context, String name, CursorFactory factory, int version)
	{
		super(context, BD_NAME, null, VERSION);
		this.mContext = context;
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL(
				"create table person_info (userid text primary key,username text,password text,paypassword text,phone text,userpic bolb,balance integer);");
		db.execSQL(
				"create table address_info(addressid text primary key,province text,city text,country text,street text,phone text);");
		db.execSQL(
				"create table redpackage_info(redpackageid text primary key,amount integer,type text,phone text,starttime text,endtime text);");
		db.execSQL(
				"create table ordermeal_info(mealid text primary key,restaurantname text,mealname text,mealnum text,mealmoney integer,phone text,isOrdered integer,restaurantid text);");
		db.execSQL(
				"create table restaurant_info(restaurantid text primary key,resname text,resphone text,canguanpic bolb,restype text,respeisong integer,runspeed text,startrunmoney integer,sales text,score text,resaddressid text);");
		db.execSQL(
				"create table menu_info (menuid text primary key,name text,price text,image bolb,restaurantid text);");
		db.execSQL(
				"create table resaddress_info(resaddressid text primary key,resprovince text,rescity text,rescountry text,resstreet text);");

		db.execSQL("create table food_album(albumid text primary key,image bolb,time text,phone text);");
		initTable_Person_Info(db, mContext);
		initTable_Address_Info(db, mContext);
		initTable_Redpackage_Info(db, mContext);
		initTable_Ordermeal_Info(db, mContext);
		initTable_Restaurant_Info(db, mContext);
		initTable_Menu_Info(db, mContext);
		initTable_Resaddress_Info(db, mContext);
		initTable_Food_Album(db, mContext);
	}

	/**
	 * ½«Drawableת»»³É¿ÉÒÔÓÃÀ´´æ´¢µÄByte[]ÀàÐÍ
	 *
	 * @param drawable
	 * @return
	 */
	private byte[] getPicture(Drawable drawable)
	{
		if (drawable == null )
		{
			return null;
		}
		BitmapDrawable bd = (BitmapDrawable) drawable;
		Bitmap bitmap = bd.getBitmap();
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		bitmap.compress(CompressFormat.PNG, 100, baos);
		return baos.toByteArray();
	}

	/**
	 * ³õ'»¯ÃÀʳÏà²á±í
	 *
	 * @param db
	 * @param mContext2
	 */
	private void initTable_Food_Album(SQLiteDatabase db, Context context)
	{
		ContentValues values = new ContentValues();
		values.put("albumid", "50000");
		Drawable drawable = context.getResources().getDrawable(R.drawable.food1);
		values.put("image", getPicture(drawable));
		values.put("time", "2016-4-1 9:14");
		values.put("phone", "13915873770");
		db.insert("food_album", null, values);

		ContentValues values1 = new ContentValues();
		values1.put("albumid", "50001");
		Drawable drawable1 = context.getResources().getDrawable(R.drawable.food2);
		values1.put("image", getPicture(drawable1));
		values1.put("time", "2016-4-2 9:14");
		values1.put("phone", "13915873770");
		db.insert("food_album", null, values1);

		ContentValues values2 = new ContentValues();
		values2.put("albumid", "50002");
		Drawable drawable2 = context.getResources().getDrawable(R.drawable.food3);
		values2.put("image", getPicture(drawable2));
		values2.put("time", "2016-4-3 9:14");
		values2.put("phone", "13915873770");
		db.insert("food_album", null, values2);

		ContentValues values3 = new ContentValues();
		values3.put("albumid", "50003");
		Drawable drawable3 = context.getResources().getDrawable(R.drawable.food4);
		values3.put("image", getPicture(drawable3));
		values3.put("time", "2016-4-4 9:14");
		values3.put("phone", "13915873770");
		db.insert("food_album", null, values3);

		ContentValues values4 = new ContentValues();
		values4.put("albumid", "50004");
		Drawable drawable4 = context.getResources().getDrawable(R.drawable.food5);
		values4.put("image", getPicture(drawable4));
		values4.put("time", "2016-4-5 9:14");
		values4.put("phone", "13915873770");
		db.insert("food_album", null, values4);

		ContentValues values5 = new ContentValues();
		values5.put("albumid", "50005");
		Drawable drawable5 = context.getResources().getDrawable(R.drawable.food6);
		values5.put("image", getPicture(drawable5));
		values5.put("time", "2016-4-6 9:14");
		values5.put("phone", "13915873770");
		db.insert("food_album", null, values5);

	}

	/**
	 * ³õ'»¯²Í¹ÝµØÖ·±íµÄÐÅÏ¢
	 *
	 * @param context
	 * @param db
	 */
	private void initTable_Resaddress_Info(SQLiteDatabase db, Context context)
	{

	}

	/**
	 * ³õ'»¯²Ëµ¥±íµÄÐÅÏ¢
	 *
	 * @param mContext2
	 * @param db
	 */
	private void initTable_Menu_Info(SQLiteDatabase db, Context context)
	{
		ContentValues values = new ContentValues();
		values.put("menuid", "6000");
		values.put("name", "¹Ò¯¿¾Ñ¼");
		values.put("price", "60");
		Drawable drawable = context.getResources().getDrawable(R.drawable.gualu);
		values.put("image", getPicture(drawable));
		values.put("restaurantid", "10000");
		db.insert("menu_info", null, values);

		ContentValues values1 = new ContentValues();
		values1.put("menuid", "6001");
		values1.put("name", "ì˯¿¾Ñ¼");
		values1.put("price", "70");
		Drawable drawable1 = context.getResources().getDrawable(R.drawable.menlu);
		values1.put("image", getPicture(drawable1));
		values1.put("restaurantid", "10000");
		db.insert("menu_info", null, values1);

		ContentValues values2 = new ContentValues();
		values2.put("menuid", "6002");
		values2.put("name", "ÍÁ¶¹Å£Èâ¸Ç½½·¹");
		values2.put("price", "12");
		Drawable drawable2 = context.getResources().getDrawable(R.drawable.galiniurougaijiaofan);
		values2.put("image", getPicture(drawable2));
		values2.put("restaurantid", "10001");
		db.insert("menu_info", null, values2);

		ContentValues values3 = new ContentValues();
		values3.put("menuid", "6003");
		values3.put("name", "·¬Çѳ´µ°¸Ç½½·¹");
		values3.put("price", "10");
		Drawable drawable3 = context.getResources().getDrawable(R.drawable.fanqiechaodan);
		values3.put("image", getPicture(drawable3));
		values3.put("restaurantid", "10001");
		db.insert("menu_info", null, values3);

		ContentValues values4 = new ContentValues();
		values4.put("menuid", "6004");
		values4.put("name", "Çཷ³´Èâ¸Ç½½·¹");
		values4.put("price", "12");
		Drawable drawable4 = context.getResources().getDrawable(R.drawable.qingjiaorousigaijiaofan);
		values4.put("image", getPicture(drawable4));
		values4.put("restaurantid", "10001");
		db.insert("menu_info", null, values4);

		ContentValues values5 = new ContentValues();
		values5.put("menuid", "6005");
		values5.put("name", "н®´óÅ̼¦");
		values5.put("price", "50");
		Drawable drawable5 = context.getResources().getDrawable(R.drawable.dapanji);
		values5.put("image", getPicture(drawable5));
		values5.put("restaurantid", "10001");
		db.insert("menu_info", null, values5);

		ContentValues values6 = new ContentValues();
		values6.put("menuid", "6006");
		values6.put("name", "ÊÖ×¥ÑòÈâ");
		values6.put("price", "30");
		Drawable drawable6 = context.getResources().getDrawable(R.drawable.shouzhuayangrou);
		values6.put("image", getPicture(drawable6));
		values6.put("restaurantid", "10001");
		db.insert("menu_info", null, values6);

		ContentValues values7 = new ContentValues();
		values7.put("menuid", "6007");
		values7.put("name", "Å£Èâ·ÛË¿ÌÀ");
		values7.put("price", "15");
		Drawable drawable7 = context.getResources().getDrawable(R.drawable.niuroufensitang);
		values7.put("image", getPicture(drawable7));
		values7.put("restaurantid", "10001");
		db.insert("menu_info", null, values7);

		ContentValues values8 = new ContentValues();
		values8.put("menuid", "6008");
		values8.put("name", "¿§à¬Å£Èâ³´·¹");
		values8.put("price", "12");
		Drawable drawable8 = context.getResources().getDrawable(R.drawable.niiurouchaofan);
		values8.put("image", getPicture(drawable8));
		values8.put("restaurantid", "10001");
		db.insert("menu_info", null, values8);

		ContentValues values9 = new ContentValues();
		values9.put("menuid", "6009");
		values9.put("name", "Å£ÈâÅÝĤ");
		values9.put("price", "8");
		Drawable drawable9 = context.getResources().getDrawable(R.drawable.paomo);
		values9.put("image", getPicture(drawable9));
		values9.put("restaurantid", "10001");
		db.insert("menu_info", null, values9);

		ContentValues values10 = new ContentValues();
		values10.put("menuid", "6010");
		values10.put("name", "Å£Èâ°èÃæ");
		values10.put("price", "12");
		Drawable drawable10 = context.getResources().getDrawable(R.drawable.niuroubanmian);
		values10.put("image", getPicture(drawable10));
		values10.put("restaurantid", "10001");
		db.insert("menu_info", null, values10);

		ContentValues values11 = new ContentValues();
		values11.put("menuid", "6011");
		values11.put("name", "ÑòÈâÌÀ");
		values11.put("price", "20");
		Drawable drawable11 = context.getResources().getDrawable(R.drawable.yangroutang);
		values11.put("image", getPicture(drawable11));
		values11.put("restaurantid", "10001");
		db.insert("menu_info", null, values11);

		ContentValues values12 = new ContentValues();
		values12.put("menuid", "6012");
		values12.put("name", "»Æì˼¦");
		values12.put("price", "15");
		Drawable drawable12 = context.getResources().getDrawable(R.drawable.huangmenji);
		values12.put("image", getPicture(drawable12));
		values12.put("restaurantid", "10003");
		db.insert("menu_info", null, values12);

		ContentValues values13 = new ContentValues();
		values13.put("menuid", "6013");
		values13.put("name", "»ÆìËÅŹÇ");
		values13.put("price", "18");
		Drawable drawable13 = context.getResources().getDrawable(R.drawable.hangmenpaigu);
		values13.put("image", getPicture(drawable13));
		values13.put("restaurantid", "10003");
		db.insert("menu_info", null, values13);

		ContentValues values14 = new ContentValues();
		values14.put("menuid", "6014");
		values14.put("name", "ºì¸»Ê¿Æ»¹û");
		values14.put("price", "10/½ï");
		Drawable drawable14 = context.getResources().getDrawable(R.drawable.pingguo);
		values14.put("image", getPicture(drawable14));
		values14.put("restaurantid", "10005");
		db.insert("menu_info", null, values14);

		ContentValues values15 = new ContentValues();
		values15.put("menuid", "6015");
		values15.put("name", "â¹û");
		values15.put("price", "12/½ï");
		Drawable drawable15 = context.getResources().getDrawable(R.drawable.manguo);
		values15.put("image", getPicture(drawable15));
		values15.put("restaurantid", "10005");
		db.insert("menu_info", null, values15);

		ContentValues values16 = new ContentValues();
		values16.put("menuid", "6016");
		values16.put("name", "Î÷¹Ï");
		values16.put("price", "5/½ï");
		Drawable drawable16 = context.getResources().getDrawable(R.drawable.xigua);
		values16.put("image", getPicture(drawable16));
		values16.put("restaurantid", "10005");
		db.insert("menu_info", null, values16);

		ContentValues values17 = new ContentValues();
		values17.put("menuid", "6017");
		values17.put("name", "²ÝÝ®µ°¸â");
		values17.put("price", "80/¸ö");
		Drawable drawable17 = context.getResources().getDrawable(R.drawable.caomeidangao);
		values17.put("image", getPicture(drawable17));
		values17.put("restaurantid", "10006");
		db.insert("menu_info", null, values17);

		ContentValues values18 = new ContentValues();
		values18.put("menuid", "6018");
		values18.put("name", "â¹ûµ°¸â");
		values18.put("price", "100/¸ö");
		Drawable drawable18 = context.getResources().getDrawable(R.drawable.manguodangao);
		values18.put("image", getPicture(drawable18));
		values18.put("restaurantid", "10006");
		db.insert("menu_info", null, values18);

		ContentValues values19 = new ContentValues();
		values19.put("menuid", "6019");
		values19.put("name", "±ùä¿Áܵ°¸â");
		values19.put("price", "120/¸ö");
		Drawable drawable19 = context.getResources().getDrawable(R.drawable.bingqiling);
		values19.put("image", getPicture(drawable19));
		values19.put("restaurantid", "10006");
		db.insert("menu_info", null, values19);

		ContentValues values20 = new ContentValues();
		values20.put("menuid", "6020");
		values20.put("name", "¸É±´ÅŹÇÖà");
		values20.put("price", "68/¹ø");
		Drawable drawable20 = context.getResources().getDrawable(R.drawable.ganbeipaigu);
		values20.put("image", getPicture(drawable20));
		values20.put("restaurantid", "10007");
		db.insert("menu_info", null, values20);

		ContentValues values21 = new ContentValues();
		values21.put("menuid", "6021");
		values21.put("name", "ϺÈÊÉ°¹øÖà");
		values21.put("price", "58/¹ø");
		Drawable drawable21 = context.getResources().getDrawable(R.drawable.xiarenzhou);
		values21.put("image", getPicture(drawable21));
		values21.put("restaurantid", "10007");
		db.insert("menu_info", null, values21);

		ContentValues values22 = new ContentValues();
		values22.put("menuid", "6022");
		values22.put("name", "з»ÆÉ°¹øÖà");
		values22.put("price", "98/¹ø");
		Drawable drawable22 = context.getResources().getDrawable(R.drawable.xiehuangzhou);
		values22.put("image", getPicture(drawable22));
		values22.put("restaurantid", "10007");
		db.insert("menu_info", null, values22);

		ContentValues values23 = new ContentValues();
		values23.put("menuid", "6023");
		values23.put("name", "´àƤÊÖǹÍÈ");
		values23.put("price", "28");
		Drawable drawable23 = context.getResources().getDrawable(R.drawable.cuipishouqiangtui);
		values23.put("image", getPicture(drawable23));
		values23.put("restaurantid", "10008");
		db.insert("menu_info", null, values23);

		ContentValues values24 = new ContentValues();
		values24.put("menuid", "6024");
		values24.put("name", "É÷¨Ó㱤");
		values24.put("price", "24");
		Drawable drawable24 = context.getResources().getDrawable(R.drawable.xueyubao);
		values24.put("image", getPicture(drawable24));
		values24.put("restaurantid", "10008");
		db.insert("menu_info", null, values24);

		ContentValues values25 = new ContentValues();
		values25.put("menuid", "6025");
		values25.put("name", "֥ʿţÅÅ·¹");
		values25.put("price", "38");
		Drawable drawable25 = context.getResources().getDrawable(R.drawable.zhishiniuroufan);
		values25.put("image", getPicture(drawable25));
		values25.put("restaurantid", "10008");
		db.insert("menu_info", null, values25);

		ContentValues values26 = new ContentValues();
		values26.put("menuid", "60026");
		values26.put("name", "ÍÁ¶¹Å£Èâ¸Ç½½·¹");
		values26.put("price", "12");
		Drawable drawable26 = context.getResources().getDrawable(R.drawable.galiniurougaijiaofan);
		values26.put("image", getPicture(drawable26));
		values26.put("restaurantid", "10002");
		db.insert("menu_info", null, values26);

		ContentValues values27 = new ContentValues();
		values27.put("menuid", "60027");
		values27.put("name", "·¬Çѳ´µ°¸Ç½½·¹");
		values27.put("price", "10");
		Drawable drawable27 = context.getResources().getDrawable(R.drawable.fanqiechaodan);
		values27.put("image", getPicture(drawable27));
		values27.put("restaurantid", "10002");
		db.insert("menu_info", null, values27);

		ContentValues values28 = new ContentValues();
		values28.put("menuid", "60028");
		values28.put("name", "Çཷ³´Èâ¸Ç½½·¹");
		values28.put("price", "12");
		Drawable drawable28 = context.getResources().getDrawable(R.drawable.qingjiaorousigaijiaofan);
		values28.put("image", getPicture(drawable28));
		values28.put("restaurantid", "10002");
		db.insert("menu_info", null, values28);

		ContentValues values29 = new ContentValues();
		values29.put("menuid", "60029");
		values29.put("name", "ÍÁ¶¹Å£Èâ¸Ç½½·¹");
		values29.put("price", "12");
		Drawable drawable29 = context.getResources().getDrawable(R.drawable.galiniurougaijiaofan);
		values29.put("image", getPicture(drawable29));
		values29.put("restaurantid", "10004");
		db.insert("menu_info", null, values29);

		ContentValues values30 = new ContentValues();
		values30.put("menuid", "60030");
		values30.put("name", "·¬Çѳ´µ°¸Ç½½·¹");
		values30.put("price", "10");
		Drawable drawable30 = context.getResources().getDrawable(R.drawable.fanqiechaodan);
		values30.put("image", getPicture(drawable30));
		values30.put("restaurantid", "10004");
		db.insert("menu_info", null, values30);

		ContentValues values31 = new ContentValues();
		values31.put("menuid", "60031");
		values31.put("name", "Çཷ³´Èâ¸Ç½½·¹");
		values31.put("price", "12");
		Drawable drawable31 = context.getResources().getDrawable(R.drawable.qingjiaorousigaijiaofan);
		values31.put("image", getPicture(drawable31));
		values31.put("restaurantid", "10004");
		db.insert("menu_info", null, values31);
	}

	/**
	 * ³õ'»¯²Í¹Ý±íµÄÐÅÏ¢
	 *
	 * @param mContext2
	 * @param db
	 */
	private void initTable_Restaurant_Info(SQLiteDatabase db, Context context)
	{
		ContentValues values = new ContentValues();
		values.put("restaurantid", "10000");
		values.put("resphone", "13915873770");
		values.put("resname", "±±¾©¿¾Ñ¼");
		Drawable drawable = context.getResources().getDrawable(R.drawable.bjky);
		values.put("canguanpic", getPicture(drawable));
		values.put("restype", "Õý²Í");
		values.put("runspeed", "30");
		values.put("startrunmoney", "15");
		values.put("sales", "0");
		values.put("score", "0");
		values.put("resaddressid", "20000");
		values.put("respeisong", "5");
		db.insert("restaurant_info", null, values);

		ContentValues values1 = new ContentValues();
		values1.put("restaurantid", "10001");
		values1.put("resphone", "13915873771");
		values1.put("resname", "À¼ÖÝÀÃæ");
		Drawable drawable1 = context.getResources().getDrawable(R.drawable.lzlm);
		values1.put("canguanpic", getPicture(drawable1));
		values1.put("restype", "¿ì²Í");
		values1.put("runspeed", "40");
		values1.put("startrunmoney", "20");
		values1.put("sales", "0");
		values1.put("score", "0");
		values1.put("respeisong", "3");
		values1.put("resaddressid", "20001");
		db.insert("restaurant_info", null, values1);

		ContentValues values2 = new ContentValues();
		values2.put("restaurantid", "10002");
		values2.put("resphone", "13915873772");
		values2.put("resname", "ɳÏØС³Ô");
		Drawable drawable2 = context.getResources().getDrawable(R.drawable.sxxc);
		values2.put("canguanpic", getPicture(drawable2));
		values2.put("restype", "С³Ô");
		values2.put("runspeed", "30");
		values2.put("startrunmoney", "30");
		values2.put("sales", "0");
		values2.put("respeisong", "3");
		values2.put("score", "0");
		values2.put("resaddressid", "20002");
		db.insert("restaurant_info", null, values2);

		ContentValues values3 = new ContentValues();
		values3.put("restaurantid", "10003");
		values3.put("resphone", "13915873773");
		values3.put("resname", "»Æì˼¦");
		Drawable drawable3 = context.getResources().getDrawable(R.drawable.hmj);
		values3.put("canguanpic", getPicture(drawable3));
		values3.put("restype", "¿ì²Í");
		values3.put("runspeed", "30");
		values3.put("startrunmoney", "20");
		values3.put("sales", "0");
		values3.put("score", "0");
		values3.put("respeisong", "2");
		values3.put("resaddressid", "20003");
		db.insert("restaurant_info", null, values3);

		ContentValues values4 = new ContentValues();
		values4.put("restaurantid", "10004");
		values4.put("resphone", "13915873774");
		values4.put("resname", "ÖØÇìСÃæ");
		Drawable drawable4 = context.getResources().getDrawable(R.drawable.cqxm);
		values4.put("canguanpic", getPicture(drawable4));
		values4.put("restype", "¿ì²Í");
		values4.put("runspeed", "40");
		values4.put("startrunmoney", "30");
		values4.put("sales", "0");
		values4.put("respeisong", "6");
		values4.put("score", "0");
		values4.put("resaddressid", "20004");
		db.insert("restaurant_info", null, values4);

		ContentValues values5 = new ContentValues();
		values5.put("restaurantid", "10005");
		values5.put("resphone", "13915873775");
		values5.put("resname", "Ò»ºÅË®¹û̯");
		Drawable drawable5 = context.getResources().getDrawable(R.drawable.yhsgt);
		values5.put("canguanpic", getPicture(drawable5));
		values5.put("restype", "Ë®¹û");
		values5.put("runspeed", "40");
		values5.put("startrunmoney", "50");
		values5.put("sales", "0");
		values5.put("respeisong", "3");
		values5.put("score", "5");
		values5.put("resaddressid", "20005");
		db.insert("restaurant_info", null, values5);

		ContentValues values6 = new ContentValues();
		values6.put("restaurantid", "10006");
		values6.put("resphone", "13915873776");
		values6.put("resname", "ÃÎÌðµ°¸â");
		Drawable drawable6 = context.getResources().getDrawable(R.drawable.mtdg);
		values6.put("canguanpic", getPicture(drawable6));
		values6.put("restype", "ÌðÆ·");
		values6.put("runspeed", "50");
		values6.put("startrunmoney", "60");
		values6.put("sales", "0");
		values6.put("score", "0");
		values6.put("respeisong", "6");
		values6.put("resaddressid", "20006");
		db.insert("restaurant_info", null, values6);

		ContentValues values7 = new ContentValues();
		values7.put("restaurantid", "10007");
		values7.put("resphone", "13915873777");
		values7.put("resname", "ÔÁ×ÐÍå");
		Drawable drawable7 = context.getResources().getDrawable(R.drawable.yzg);
		values7.put("canguanpic", getPicture(drawable7));
		values7.put("restype", "Õý²Í");
		values7.put("runspeed", "40");
		values7.put("startrunmoney", "100");
		values7.put("sales", "0");
		values7.put("respeisong", "8");
		values7.put("score", "0");
		values7.put("resaddressid", "20007");
		db.insert("restaurant_info", null, values7);

		ContentValues values8 = new ContentValues();
		values8.put("restaurantid", "10008");
		values8.put("resphone", "13915873778");
		values8.put("resname", "¿Ï´ò¼¦");
		Drawable drawable8 = context.getResources().getDrawable(R.drawable.kdj);
		values8.put("canguanpic", getPicture(drawable8));
		values8.put("restype", "С³Ô");
		values8.put("runspeed", "30");
		values8.put("startrunmoney", "50");
		values8.put("sales", "0");
		values8.put("score", "0");
		values8.put("respeisong", "10");
		values8.put("resaddressid", "20008");
		db.insert("restaurant_info", null, values8);
	}

	/**
	 * ³õ'»¯¶©µ¥±íµÄÐÅÏ¢
	 *
	 * @param mContext2
	 * @param db
	 */
	private void initTable_Ordermeal_Info(SQLiteDatabase db, Context mContext2)
	{

	}

	/**
	 * ³õ'»¯ºì°ü±íµÄÐÅÏ¢
	 *
	 * @param mContext2
	 * @param db
	 */
	private void initTable_Redpackage_Info(SQLiteDatabase db, Context mContext2)
	{
		ContentValues values = new ContentValues();
		values.put("redpackageid", "500");
		values.put("amount", "100");
		values.put("type", "¹ÜÀíÔ±ºì°ü");
		values.put("starttime", "1970-01-01");
		values.put("endtime", "2100-12-31");
		values.put("phone", "13915873770");
		db.insert("redpackage_info", null, values);

		ContentValues values1 = new ContentValues();
		values1.put("redpackageid", "501");
		values1.put("amount", "500");
		values1.put("type", "¹ÜÀíÔ±ºì°ü");
		values1.put("starttime", "1970-01-01");
		values1.put("endtime", "2100-12-31");
		values1.put("phone", "13915873770");
		db.insert("redpackage_info", null, values1);
	}

	/**
	 * ³õ'»¯Óû§µØÖ·±íµÄÐÅÏ¢
	 *
	 * @param mContext2
	 * @param db
	 */
	private void initTable_Address_Info(SQLiteDatabase db, Context context)
	{
		ContentValues values = new ContentValues();
		values.put("addressid", "500");
		values.put("province", "½ËÕÊ¡");
		values.put("city", "³£ÖÝÊÐ");
		values.put("country", "äàÑôÏØ");
		values.put("street", "Éçä¾ÕòũóÊг¡±±Â¥");
		values.put("phone", "13915873770");
		db.insert("address_info", null, values);
	}

	/**
	 * ³õ'»¯Óû§±íµÄÐÅÏ¢
	 *
	 * @param mContext2
	 * @param db
	 */
	private void initTable_Person_Info(SQLiteDatabase db, Context context)
	{
		ContentValues values = new ContentValues();
		values.put("userid", "100");
		values.put("username", "admin");
		values.put("password", "admin");
		values.put("paypassword", "123456");
		Drawable drawable = context.getResources().getDrawable(R.drawable.admin);
		values.put("phone", "13915873770");
		values.put("userpic", getPicture(drawable));
		values.put("balance", "10000");
		db.insert("person_info", null, values);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		System.out.println("oldVersion:" + oldVersion + "newVersion:" + newVersion);
		db.execSQL("drop table if exists resaddress_info");
		db.execSQL("drop table if exists menu_info");
		db.execSQL("drop table if exists restaurant_info");
		db.execSQL("drop table if exists ordermeal_info");
		db.execSQL("drop table if exists redpackage_info");
		db.execSQL("drop table if exists address_info");
		db.execSQL("drop table if exists person_info");
		db.execSQL("drop table if exists food_album");
		onCreate(db);
	}

}


text:
$(function () {
  // 'use strict'

  // Load demo images from flickr:
  $.ajax({
    // Flickr API is SSL only:
    // https://code.flickr.net/2014/04/30/flickr-api-going-ssl-only-on-june-27th-2014/
    url: 'https://api.flickr.com/services/rest/',
    data: {
      format: 'json',
      method: 'flickr.people.getPublicPhotos',
      api_key: 'bf5ec2d88cc0ea4b96c69dfd70536885', // jshint ignore:line
      // photoset_id:'72157669308506681',
      user_id: '143393980@N04'
    },
    dataType: 'jsonp',
    jsonp: 'jsoncallback'
  }).done(function (result) {
    var carouselLinks = []
    var linksContainer = $('#links')
    var baseUrl
    // Add the demo images as links with thumbnails to the page:
    $.each(result.photos.photo, function (index, photo) {
      baseUrl = 'https://farm' + photo.farm + '.static.flickr.com/' +
      photo.server + '/' + photo.id + '_' + photo.secret
      $('<a/>')
        .append($('<img>').prop('src', baseUrl + '_s.jpg'))
        .prop('href', baseUrl + '_b.jpg')
        .prop('title', photo.title)
        .attr('data-gallery', '')
        .appendTo(linksContainer)
      carouselLinks.push({
        href: baseUrl + '_c.jpg',
        title: photo.title
      })
    })
    // Initialize the Gallery as image carousel:
    blueimp.Gallery(carouselLinks, {
      container: '#blueimp-image-carousel',
      carousel: true
    })
  })
})

$(window).load(function(){

  $('.show-file').on("click",function(){
    $('.flipbook-viewport').show();
    $('body').css('overflow','hidden');
});

$('.flipbook-bg').on("click",function(){
    $('.flipbook-viewport').hide();
    $('body').css('overflow','scroll');
});

});


text:
package org.simondean.mingle.extractor.config;

import java.util.List;

public class Config {
  private final List<Server> servers;

  public Config(List<Server> servers) {
    this.servers = servers;
  }

  public List<Server> servers() {
    return servers;
  }
}


text:
package org.onosproject.store.intent.impl;

import com.google.common.base.MoreObjects;

import java.util.Objects;

/**
 * Identifies a partition of the intent keyspace which will be assigned to and
 * processed by a single ONOS instance at a time.
 */
public class PartitionId {
    private final int id;

    /**
     * Creates a new partition ID.
     *
     * @param id the partition ID
     */
    PartitionId(int id) {
        this.id = id;
    }

    /**
     * Returns the integer ID value.
     *
     * @return ID value
     */
    public int value() {
        return id;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof PartitionId)) {
            return false;
        }

        PartitionId that = (PartitionId) o;
        return Objects.equals(this.id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(getClass())
                .add("partition ID", id)
                .toString();
    }
}


text:
@implementation SLAPIManager
+ (instancetype)sharedApi
{
    static dispatch_once_t onceToken;
    static id instance;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc]init];
    });
    return instance;
}

- (void)requestHeadLineDataWithURL:(NSString *)url success:(void (^)(id))success error:(void (^)(NSError *))error
{
    [[SLHTTPManager shanredManager]GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (success) {
            success(responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull errorInfo) {
        if (error) {
            error(errorInfo);
        }
    }];
}

- (void)requestNewsDataWithURL:(NSString *)url success:(void (^)(id))success error:(void (^)(NSError *))error
{
    [[SLHTTPManager shanredManager]GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (success) {
            success(responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull errorInfo) {
        if (error) {
            error(errorInfo);
        }
    }];
}
@end


text:
package com.jungle.majorhttps.request.base;

import com.android.volley.NetworkResponse;

public class BizBaseResponse<T> {

    public T mContent;
    public NetworkResp mNetworkResp;

    public BizBaseResponse(NetworkResponse response, T content) {
        mContent = content;
        mNetworkResp = new NetworkResp(response);
    }
}