JavaGenerator.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. package org.apache.jute.compiler;
  19. import java.util.ArrayList;
  20. import java.io.File;
  21. import java.io.FileWriter;
  22. import java.io.IOException;
  23. import java.util.Iterator;
  24. /**
  25. * Java Code generator front-end for Hadoop record I/O.
  26. *
  27. * @author Milind Bhandarkar
  28. */
  29. class JavaGenerator {
  30. private String mName;
  31. private ArrayList mInclFiles;
  32. private ArrayList mRecList;
  33. /** Creates a new instance of JavaGenerator
  34. *
  35. * @param name possibly full pathname to the file
  36. * @param incl included files (as JFile)
  37. * @param records List of records defined within this file
  38. */
  39. JavaGenerator(String name, ArrayList incl, ArrayList records) {
  40. mName = name;
  41. mInclFiles = incl;
  42. mRecList = records;
  43. }
  44. /**
  45. * Generate Java code for records. This method is only a front-end to
  46. * JRecord, since one file is generated for each record.
  47. */
  48. void genCode() throws IOException {
  49. for (Iterator i = mRecList.iterator(); i.hasNext(); ) {
  50. JRecord rec = (JRecord) i.next();
  51. rec.genJavaCode();
  52. }
  53. }
  54. }