Package com.asakusafw.runtime.directio

Examples of com.asakusafw.runtime.directio.FilePattern$Token


        Map<DirectInputGroup, List<InputPath>> results = new HashMap<DirectInputGroup, List<InputPath>>();
        for (StageInput input : inputList) {
            String fullBasePath = variables.parse(extractBasePath(input));
            String basePath = repo.getComponentPath(fullBasePath);
            FilePattern pattern = extractSearchPattern(context, variables, input);
            Class<?> dataClass = extractDataClass(context, input);
            Class<? extends DataFormat<?>> formatClass = extractFormatClass(context, input);
            DirectInputGroup group = new DirectInputGroup(fullBasePath, dataClass, formatClass);
            List<InputPath> paths = results.get(group);
            if (paths == null) {
View Full Code Here


        assert context != null;
        assert input != null;
        String value = extract(input, DirectDataSourceConstants.KEY_RESOURCE_PATH);
        value = variables.parse(value);
        try {
            FilePattern compiled = FilePattern.compile(value);
            if (compiled.containsVariables()) {
                throw new IllegalArgumentException(MessageFormat.format(
                        "Search pattern contains variables: {0}",
                        value));
            }
            return compiled;
View Full Code Here

                OutputTransactionContext context = HadoopDataSourceUtil.createContext(jobContext, id);
                try {
                    DirectDataSource repo = repository.getRelatedDataSource(spec.basePath);
                    String basePath = repository.getComponentPath(spec.basePath);
                    for (String pattern : spec.deletePatterns) {
                        FilePattern resources = FilePattern.compile(pattern);
                        if (LOG.isInfoEnabled()) {
                            LOG.info(MessageFormat.format(
                                    "Deleting output: datasource={0}, basePath={1}, pattern={2}",
                                    id,
                                    basePath,
View Full Code Here

                    "Start finding input (id={0}, path={1}, resourcePattern={2})",
                    profile.getId(),
                    basePath,
                    resourcePattern));
        }
        FilePattern pattern = validate(resourcePattern);
        HadoopDataSourceProfile p = profile;
        FileSystem fs = p.getFileSystem();
        Path root = p.getFileSystemPath();
        Path base = append(root, basePath);
        Path temporary = p.getTemporaryFileSystemPath();
View Full Code Here

                    "Start listing files (id={0}, path={1}, resource={2})",
                    profile.getId(),
                    basePath,
                    resourcePattern));
        }
        FilePattern pattern = validate(resourcePattern);
        HadoopDataSourceProfile p = profile;
        FileSystem fs = p.getFileSystem();
        Path root = p.getFileSystemPath();
        Path base = append(root, basePath);
        Path temporary = p.getTemporaryFileSystemPath();
View Full Code Here

                    profile.getId(),
                    basePath,
                    resourcePattern,
                    recursive));
        }
        FilePattern pattern = validate(resourcePattern);
        HadoopDataSourceProfile p = profile;
        FileSystem fs = p.getFileSystem();
        Path root = p.getFileSystemPath();
        Path base = append(root, basePath);
        List<FileStatus> stats = HadoopDataSourceUtil.search(fs, base, pattern);
View Full Code Here

   *         11 mars 07<br>
   * @param args
   */
  @SuppressWarnings("boxing")
  public static void main(String[] args) {
    Token token1 = null;
    Token token2 = null;
    byte[] userId = "Dominique_Dominique".getBytes();
    byte[] tempEncrypt = null;
    byte[] tempDecrypt = null;
    byte[] msgToCrypt = null;
    byte[] tempEncodedBase64 = null;
    byte[] tempDecodedBase64 = null;
    byte[] tempBytes = null;
    byte[] myBytes = new byte[15];
    Date creationDate = new Date();
    ASN1Sequence sequenceASN1 = null;
    ASN1InputStream inASN1 = null;
    SymmetricKeyCipher symmetricKeyCipher = null;
    int i = 0;
    int myInt = 30;

    /*
     * Sample : Creating a ASN1 structure, Encrypt and decrypt it with
     * symmetric key algorithm (check equality before and after), Encode and
     * decode it in Base64 (check equality before and after).
     */
    System.out.println("---[Bouncy Castle Sample]---");
    try {
      /* ASN1 Sample */
      myBytes[0] = 1;
      myBytes[1] = 2;
      myBytes[2] = 4;
      myBytes[8] = -3;
      System.out.println("[ASN1 Sample]");
      System.out
          .println("**Sample 1 : Conctructor with direct java object**");
      token1 = new Token(userId, myBytes, myInt, creationDate);
      inASN1 = new ASN1InputStream(token1.getEncoded());
      System.out.println("DumpAsString on Java Object");
      System.out.println(ASN1Dump.dumpAsString(token1));
      System.out.println("DumpAsString on Object from ASN1InputStream");
      System.out.println(ASN1Dump.dumpAsString(inASN1.readObject()));
      // -
      System.out.println("**Sample 2 : Conctructor with ASN1 sequence**");
      sequenceASN1 = ASN1Sequence.getInstance(token1.toASN1Object());
      token2 = new Token(sequenceASN1);
      inASN1 = new ASN1InputStream(token2.getEncoded());
      System.out.println("DumpAsString on Java Object");
      System.out.println(ASN1Dump.dumpAsString(token2));
      System.out.println("DumpAsString on Object from ASN1InputStream");
      System.out.println(ASN1Dump.dumpAsString(inASN1.readObject()));
      System.out.println("--");
      System.out.println("------");
      System.out.println("--\n");
      /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
      /* Cipher Sample */
      System.out.println("[Cipher Sample]");
      symmetricKeyCipher = new SymmetricKeyCipher();
      token1 = new Token(userId, myBytes, myInt, creationDate);
      msgToCrypt = token1.getEncoded();
      System.out.println("Token As String before encryption : ");
      System.out.println(ASN1Dump.dumpAsString(token1));
      System.out.println("**Sample 1 : Encryption**");
      System.out.println("Original bytes : ");
      System.out.print("[");
      for (i = 0; i < msgToCrypt.length; i++) {
        System.out.print(msgToCrypt[i]);
        System.out.print(";");
      }
      System.out.println("]");
      tempEncrypt = symmetricKeyCipher.encrypt(msgToCrypt);
      System.out.println("Encrypted bytes : ");
      System.out.print("[");
      for (i = 0; i < tempEncrypt.length; i++) {
        System.out.print(tempEncrypt[i]);
        System.out.print(";");
      }
      System.out.println("]");
      System.out.println("Encrypted bytes in HEX :");
      System.out.println(new String(Hex.encode(tempEncrypt)));
      System.out.println("**Sample 2 : Decryption**");
      tempDecrypt = symmetricKeyCipher.decrypt(tempEncrypt);
      System.out.println("Decrypted bytes : ");
      System.out.print("[");
      for (i = 0; i < tempDecrypt.length; i++) {
        System.out.print(tempDecrypt[i]);
        System.out.print(";");
      }
      System.out.println("]\n");
      System.out.println("Token As String after decryption : ");
      sequenceASN1 = ASN1Sequence.getInstance(ASN1Object
          .fromByteArray(tempDecrypt));
      token2 = new Token(sequenceASN1);
      System.out.println(ASN1Dump.dumpAsString(token2));
      if (ASN1Dump.dumpAsString(token1).equals(
          ASN1Dump.dumpAsString(token2))) {
        System.out
            .println("OK - Token is equal before and after encryption/decryption !");
      } else {
        System.err
            .println("KO - Token isn't equal before and after encryption/decryption !");
      }
      System.out.println("\n--");
      System.out.println("------");
      System.out.println("--\n");
      /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
      /* Base64 Sample */
      System.out.println("[Base64 Sample]");
      tempBytes = token2.getEncoded();
      System.out.println("Original bytes : ");
      System.out.print("[");
      for (i = 0; i < tempBytes.length; i++) {
        System.out.print(tempBytes[i]);
        System.out.print(";");
      }
      System.out.println("]");
      tempEncodedBase64 = Base64.encode(tempBytes);
      System.out.println("Base 64 encoded bytes : ");
      System.out.print("[");
      for (i = 0; i < tempEncodedBase64.length; i++) {
        System.out.print(tempEncodedBase64[i]);
        System.out.print(";");
      }
      System.out.println("]");
      tempDecodedBase64 = Base64.decode(tempEncodedBase64);
      System.out.println("Base 64 decoded bytes : ");
      System.out.print("[");
      for (i = 0; i < tempDecodedBase64.length; i++) {
        System.out.print(tempDecodedBase64[i]);
        System.out.print(";");
      }
      System.out.println("]");
      System.out.println("Token As String after decoding : ");
      sequenceASN1 = ASN1Sequence.getInstance(ASN1Object
          .fromByteArray(tempDecodedBase64));
      token2 = new Token(sequenceASN1);
      System.out.println(ASN1Dump.dumpAsString(token2));
      System.out.println("\n--");
      System.out.println("------");
      System.out.println("--\n");
      /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
      /* DER Objects Access */
      System.out.printf("USER ID          : {%s}\n", new String(token2
          .getUserId().getOctets()));
      System.out.printf("DER APP SPEC[%s] : {", token2.getDerAppSpec()
          .getContents().length);
      for (byte b : token2.getDerAppSpec().getContents()) {
        System.out.printf(" %s ", b);
      }
      System.out.println("}");
      System.out.printf("DER INTEGER      : {%s}\n", token2
          .getDerInteger().getValue());
      System.out.printf("CREATION DATE    : {%s}\n", token2
          .getCreationDate().getDate());
      System.out.println("\n\n");
      System.out.println(".:ALL IS OK:.");
    } catch (Exception exp) {
      exp.printStackTrace();
View Full Code Here

    boolean inAttribute = false;
    boolean inAnchorTag = false;
    boolean inHrefAttribute = false;
    int tokenEndColumn = 0;
    for (int i = 0, l = tokens.size() - 1; i < l; i++) {
      Token token = tokens.get(i);
      TokenType type = token.getType();
      String value = token.getValue();
      int tokenStartColumn = tokenEndColumn;
      tokenEndColumn += value.length()// Exclusive.
      if (type == TokenType.TAG) {
        if (">".equals(value) || "/>".equals(value)) {
          inAttribute = false;
View Full Code Here

        && "a".equalsIgnoreCase(parserState.getState().getContext().getTagName())) {
      inAnchorTag = true;
    }
    int tokenEndColumn = 0;
    for (int i = 0, l = tokens.size() - 1; i < l; i++) {
      Token token = tokens.get(i);
      TokenType type = token.getType();
      String value = token.getValue();
      int tokenStartColumn = tokenEndColumn;
      tokenEndColumn += value.length();
      if (type == TokenType.TAG) {
        if (">".equals(value) || "/>".equals(value)) {
          inAnchorTag = false;
View Full Code Here

    @Override
    public CompletionContext<State> buildContext(
        SelectionModel selection, DocumentParser parser) {
      JsonArray<Token> tokens = JsonCollections.createArray();
      State state = TestUtils.createMockState();
      tokens.add(new Token(null, NULL, ""));
      ParseResult<State> parseResult = new ParseResult<State>(tokens, state) {};
      return buildContext(
          new ParseUtils.ExtendedParseResult<State>(parseResult, ParseUtils.Context.IN_CODE));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.directio.FilePattern$Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.