JField.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 com.yahoo.jute.compiler;
  19. /**
  20. *
  21. * @author Milind Bhandarkar
  22. */
  23. public class JField {
  24. private JType mType;
  25. private String mName;
  26. /**
  27. * Creates a new instance of JField
  28. */
  29. public JField(JType type, String name) {
  30. mType = type;
  31. mName = name;
  32. }
  33. public String getSignature() {
  34. return mType.getSignature();
  35. }
  36. public String genCppDecl() {
  37. return mType.genCppDecl(mName);
  38. }
  39. public String genCDecl() {
  40. return mType.genCDecl(mName);
  41. }
  42. public String genJavaDecl() {
  43. return mType.genJavaDecl(mName);
  44. }
  45. public String genJavaConstructorParam(String fname) {
  46. return mType.genJavaConstructorParam(fname);
  47. }
  48. public String getName() {
  49. return mName;
  50. }
  51. public String getTag() {
  52. return mName;
  53. }
  54. public JType getType() {
  55. return mType;
  56. }
  57. public String genCppGetSet(int fIdx) {
  58. return mType.genCppGetSet(mName, fIdx);
  59. }
  60. public String genJavaGetSet(int fIdx) {
  61. return mType.genJavaGetSet(mName, fIdx);
  62. }
  63. public String genJavaWriteMethodName() {
  64. return mType.genJavaWriteMethod(getName(), getTag());
  65. }
  66. public String genJavaReadMethodName() {
  67. return mType.genJavaReadMethod(getName(), getTag());
  68. }
  69. public String genJavaCompareTo() {
  70. return mType.genJavaCompareTo(getName());
  71. }
  72. public String genJavaEquals() {
  73. return mType.genJavaEquals(getName(), "peer."+getName());
  74. }
  75. public String genJavaHashCode() {
  76. return mType.genJavaHashCode(getName());
  77. }
  78. public String genJavaConstructorSet(String fname) {
  79. return mType.genJavaConstructorSet(mName, fname);
  80. }
  81. }