public static bool AddInstanceVariable(Variable variable) { if (instance == null) { instance = new ArrayList(); } Variable old = GetVariable(instance, variable.Name); if (old == null) { instance.Add(variable); return true; } else { return false; } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { ClassInfo ci = new ClassInfo(); ci.FileName = "HelloWorldExample.java"; ci.ClassName = "HelloWorldExample"; ci.Access = "public"; ci.Type = "class"; Method m = new Method(); m.Name = "main"; m.Access = "public"; m.Attributes = new String[1] { "static" }; m.ReturnType = "void"; Variable v = new Variable(); v.Name = "args"; v.Type = "String[]";//edit dimension here m.AddParameter(v); m.Code = "System.out.println(\"Hello World!\");"; ci.AddMethod(m); InsertTemplate(ci); }
private void toolStripMenuItem1_Click(object sender, EventArgs e) { NewClass nc = new NewClass(tabControl2.SelectedTab.Name); nc.ShowDialog(); if (nc.Successful) { ClassInfo ci = new ClassInfo(); ci.FileName = nc.Contents + ".java"; ci.ClassName = nc.Contents; ci.Access = "public"; ci.Type = "class"; if (nc.HasConstructor) { Method m = new Method(); m.Name = ci.ClassName; m.Access = "public"; ci.AddMethod(m); } if (nc.HasMain) { Method m = new Method(); m.Name = "main"; m.Access = "public"; m.Attributes = new String[1] { "static" }; m.ReturnType = "void"; Variable v = new Variable(); v.Name = "args"; v.Type = "String[]"; //edit dimension here v.Method = m.Name; m.AddParameter(v); ci.AddMethod(m); } InsertTemplate(ci); } }
public Boolean RemoveinstanceVariable(Variable v) { if (instanceVar.Contains(v)) { instanceVar.Remove(v); return true; } else { return false; } }
public Boolean ContainsinstanceVariable(Variable v) { return instanceVar.Contains(v); }
public void AddInstanceVariable(Variable v) { Variable old = GetinstanceVariable(v.Name); if (old != null) { RemoveinstanceVariable(old); } instanceVar.Add(v); }
public Boolean RemoveVariable(Variable v) { if (variables.Contains(v)) { variables.Remove(v); return true; } else { return false; } }
public Boolean ContainsVariable(Variable v) { return variables.Contains(v); }
public void AddVariable(Variable v) { Variable old = GetVariable(v.Name); if (old != null) { RemoveVariable(old); } variables.Add(v); }
public void AddParameter(Variable v) { parameters.Add(v); }
public static void AddLocalVariable(Variable variable) { Variable old = GetVariable(local, variable.Name); if (old != null) { RemoveLocalVariable(old); } local.Add(variable); }
public static Boolean RemoveLocalVariable(Variable variable) { if (local.Contains(variable)) { local.Remove(variable); return true; } else { return false; } }
public static Boolean RemoveInstanceVariable(Variable variable) { if (instance.Contains(variable)) { instance.Remove(variable); return true; } else { return false; } }
public static void InitializeContents() { instance = new ArrayList(); local = new ArrayList(); classes = new ArrayList(); ci = new ClassInfo(); m = new Method(); ci.ClassName = "Object"; m.Name = "toString"; m.Access = "public"; m.Attributes = null; m.ReturnType = "String"; m.Parameters = new ArrayList(); ci.AddMethod(m); classes.Add(ci); ci = new ClassInfo(); ci.ClassName = "Character"; m = new Method(); m.Name = "isUpperCase"; m.Access = "public"; m.Attributes = new String[1]{"static"}; m.ReturnType = "boolean"; m.Parameters = new ArrayList(); v = new Variable(); v.Name = "ch"; v.Type = "char"; m.Parameters.Add(v); ci.AddMethod(m); m = new Method(); m.Name = "isDigit"; m.Access = "public"; m.Attributes = new String[1]{"static"}; m.ReturnType = "boolean"; m.Parameters = new ArrayList(); v = new Variable(); v.Name = "ch"; v.Type = "char"; m.Parameters.Add(v); ci.AddMethod(m); classes.Add(ci); }
public static Boolean ContainsInstanceVariable(Variable variable) { return instance.Contains(variable); }
private bool IsNumeric(Variable v) { return v.Type == "byte" || v.Type == "double" || v.Type == "float" || v.Type == "int" || v.Type == "long" || v.Type == "short"; }