source: proiecte/HadoopJUnit/hadoop-0.20.1/src/core/org/apache/hadoop/record/compiler/JFile.java @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1/**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package org.apache.hadoop.record.compiler;
20
21import java.io.IOException;
22import java.util.ArrayList;
23
24/**
25 * Container for the Hadoop Record DDL.
26 * The main components of the file are filename, list of included files,
27 * and records defined in that file.
28 */
29public class JFile {
30  /** Possibly full name of the file */
31  private String mName;
32  /** Ordered list of included files */
33  private ArrayList<JFile> mInclFiles;
34  /** Ordered list of records declared in this file */
35  private ArrayList<JRecord> mRecords;
36   
37  /** Creates a new instance of JFile
38   *
39   * @param name possibly full pathname to the file
40   * @param inclFiles included files (as JFile)
41   * @param recList List of records defined within this file
42   */
43  public JFile(String name, ArrayList<JFile> inclFiles,
44               ArrayList<JRecord> recList) {
45    mName = name;
46    mInclFiles = inclFiles;
47    mRecords = recList;
48  }
49   
50  /** Strip the other pathname components and return the basename */
51  String getName() {
52    int idx = mName.lastIndexOf('/');
53    return (idx > 0) ? mName.substring(idx) : mName; 
54  }
55   
56  /** Generate record code in given language. Language should be all
57   *  lowercase.
58   */
59  public int genCode(String language, String destDir, ArrayList<String> options)
60    throws IOException {
61    CodeGenerator gen = CodeGenerator.get(language);
62    if (gen != null) {
63      gen.genCode(mName, mInclFiles, mRecords, destDir, options);
64    } else {
65      System.err.println("Cannnot recognize language:"+language);
66      return 1;
67    }
68    return 0;
69  }
70}
Note: See TracBrowser for help on using the repository browser.