/// <summary> /// Retorna solo la descripción del alias /// Alain Ramírez Cabrejas /// </summary> /// <returns>Descripción del Alias</returns> public String ToStringDescription() { String s = ""; if (_rhsType == RHS_ATOM) { s = s + _atom; } else if (_rhsType == RHS_LIST) { if (_listType == LIST_REGULAR) { for (int i = 0; i < ListSize; i++) { s = s + getListElement(i).ToString(); } } else if (_listType == LIST_COMMASEP) { s = s + " ("; for (int j = 0; j < ListSize; j++) { NVPair nvpair = getListElement(j); s = s + nvpair.Name; if (j != ListSize - 1) { s = s + ", "; } } s = s + ")"; } } return(s); }
private NVPair _readTopLevelNVPair(NVTokens nvtokens) { int i = nvtokens.Token; nvtokens.eatToken(); if (i != 1) { throw new TnsException("Error de sintaxis no válida."); } String s = _readNVLiteral(nvtokens); NVPair nvpair = new NVPair(s); if ((i = nvtokens.Token) == 3) { for (; i == 8 || i == 3; i = nvtokens.Token) { s = s + nvtokens.popLiteral(); } nvpair.Name = s; return(_readRightHandSide(nvpair, nvtokens)); } else { return(_readRightHandSide(nvpair, nvtokens)); } }
/// <remarks/> public virtual void initFromNVPair(NVPair nvpair) { if (nvpair.ListSize != 1) { throw new TnsException(); } NVPair nvpair1 = nvpair.getListElement(0); if (nvpair1.Name.ToUpper().Equals("DESCRIPTION_LIST".ToUpper())) { child = f.create(3); } else if (nvpair1.Name.ToUpper().Equals("DESCRIPTION".ToUpper())) { child = f.create(2); } else if (nvpair1.Name.ToUpper().Equals("ADDRESS_LIST".ToUpper())) { child = f.create(1); } else if (nvpair1.Name.ToUpper().Equals("ADDRESS".ToUpper())) { child = f.create(0); } else { throw new TnsException(); } child.initFromNVPair(nvpair1); name = nvpair.Name; }
/// <remarks/> public virtual void writeToStream(StreamWriter writer, String s, String s1) { StreamWriter printwriter; printwriter = new StreamWriter(new StreamWriter(writer.BaseStream, writer.Encoding).BaseStream, new StreamWriter(writer.BaseStream, writer.Encoding).Encoding); printwriter.WriteLine("# " + s + " Network Configuration File: " + s1 + ""); printwriter.WriteLine("# Generated by Oracle configuration tools."); printwriter.WriteLine(""); if (hasGroups) { saveNLPGroups(printwriter); } IEnumerator enumeration = ht.Values.GetEnumerator(); do { if (!enumeration.MoveNext()) { break; } NVPair nvpair = (NVPair)enumeration.Current; String s3 = nvpair.toString(0, true); if (!s3.Equals("")) { char[] ac = new char[s3.Length - 2]; SupportClass.GetCharsFromString(s3, 1, s3.Length - 1, ac, 0); String s2 = new String(ac); printwriter.WriteLine(s2); printwriter.WriteLine(""); } } while (true); printwriter.Close(); }
/// <remarks/> public virtual void initFromNVPair(NVPair nvpair) { init(); int i = nvpair.ListSize; if (i == 0) { throw new Exception(); } for (int j = 0; j < i; j++) { childnv = nvpair.getListElement(j); if (childnv.Name.ToUpper().Equals("SOURCE_ROUTE".ToUpper())) { sourceRoute = childnv.Atom.ToUpper().Equals("yes".ToUpper()) || childnv.Atom.ToUpper().Equals("on".ToUpper()) || childnv.Atom.ToUpper().Equals("true".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("LOAD_BALANCE".ToUpper())) { loadBalance = childnv.Atom.ToUpper().Equals("yes".ToUpper()) || childnv.Atom.ToUpper().Equals("on".ToUpper()) || childnv.Atom.ToUpper().Equals("true".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("FAILOVER".ToUpper())) { failover = childnv.Atom.ToUpper().Equals("yes".ToUpper()) || childnv.Atom.ToUpper().Equals("on".ToUpper()) || childnv.Atom.ToUpper().Equals("true".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("ADDRESS".ToUpper())) { child = f.create(0); child.initFromNVPair(childnv); children.Add(child); continue; } if (childnv.Name.ToUpper().Equals("ADDRESS_LIST".ToUpper())) { child = f.create(1); child.initFromNVPair(childnv); children.Add(child); } else { throw new Exception(); } } if (children.Count == 0) { throw new Exception(); } else { return; } }
/// <remarks/> public virtual void initFromString(String s) { if (s[0] != '(') { s = "(" + s + ")"; } NVPair nvpair = (new NVFactory()).createNVPair(s); initFromNVPair(nvpair); }
/// <remarks/> public void addListElement(NVPair nvpair) { if (_list == null) { _rhsType = RHS_LIST; _list = ArrayList.Synchronized(new ArrayList(3)); _atom = null; } _list.Add(nvpair); nvpair._setParent(this); }
/// <remarks/> public override String ToString() { String s = ""; for (IEnumerator enumeration = ht.Values.GetEnumerator(); enumeration.MoveNext();) { NVPair nvpair = (NVPair)enumeration.Current; String s1 = nvpair.ToString(); s = s + s1 + "\n"; } return(s); }
/// <remarks/> public virtual NVPair findNVPair(NVPair nvpair, String[] as_Renamed) { NVPair nvpair1 = nvpair; for (int i = 0; i < as_Renamed.Length; i++) { nvpair1 = findNVPair(nvpair1, as_Renamed[i]); if (nvpair1 == null) { return(null); } } return(nvpair1); }
private NVPair _readNVPair(NVTokens nvtokens) { int i = nvtokens.Token; nvtokens.eatToken(); if (i != 1 && i != 3) { throw new TnsException("Error de sintaxis no válida."); } else { String s = _readNVLiteral(nvtokens); NVPair nvpair = new NVPair(s); return(_readRightHandSide(nvpair, nvtokens)); } }
/// <remarks/> public virtual NVPair findNVPair(NVPair nvpair, String s) { if (nvpair == null || nvpair.RHSType != NVPair.RHS_LIST) { return(null); } for (int i = 0; i < nvpair.ListSize; i++) { NVPair nvpair1 = nvpair.getListElement(i); if (s.ToUpper().Equals(nvpair1.Name.ToUpper())) { return(nvpair1); } } return(null); }
private void _readNVList(NVTokens nvtokens, NVPair nvpair) { int i = nvtokens.Token; if (i != 1 && i != 3) { return; } NVPair nvpair1 = _readNVPair(nvtokens); nvpair.addListElement(nvpair1); if ((i == 3 || nvpair1.Name == nvpair1.Atom) && nvpair.ListType != NVPair.LIST_COMMASEP) { nvpair.ListType = NVPair.LIST_COMMASEP; } _readNVList(nvtokens, nvpair); }
private NVPair _readRightHandSide(NVPair nvpair, NVTokens nvtokens) { int i; switch (nvtokens.Token) { case 4: // '\004' nvtokens.eatToken(); i = nvtokens.Token; if (i == 8) { String s = _readNVLiteral(nvtokens); nvpair.Atom = s; } else { _readNVList(nvtokens, nvpair); } break; case 2: // '\002' case 3: // '\003' nvpair.Atom = nvpair.Name; break; default: throw new TnsException("Error de sintaxis no válida."); } i = nvtokens.Token; if (i == 2) { nvtokens.eatToken(); } else if (i != 3) { throw new TnsException("Error de sintaxis no válida: Carácter o LITERAL inesperado"); } return(nvpair); }
/// <remarks/> public virtual void initFromNVPair(NVPair nvpair) { init(); if (nvpair == null || !nvpair.Name.ToUpper().Equals("address".ToUpper())) { throw new Exception(); } NVNavigator nvnavigator = new NVNavigator(); NVPair nvpair1 = nvnavigator.findNVPair(nvpair, "PROTOCOL"); if (nvpair1 == null) { throw new Exception(); } prot = nvpair1.Atom; if (addr == null) { addr = nvpair.ToString(); } }
/// <remarks/> public virtual NVPair findNVPairRecurse(NVPair nvpair, String s) { if (nvpair == null || s.ToUpper().Equals(nvpair.Name.ToUpper())) { return(nvpair); } if (nvpair.RHSType == NVPair.RHS_ATOM) { return(null); } for (int i = 0; i < nvpair.ListSize; i++) { NVPair nvpair1 = findNVPairRecurse(nvpair.getListElement(i), s); if (nvpair1 != null) { return(nvpair1); } } return(null); }
/// <remarks/> public virtual void initFromString(String s) { NVPair nvpair = (new NVFactory()).createNVPair(s); initFromNVPair(nvpair); }
/// <remarks/> public virtual void initFromNVPair(NVPair nvpair) { init(); int i = nvpair.ListSize; if (i == 0) { throw new TnsException(); } for (int j = 0; j < i; j++) { childnv = nvpair.getListElement(j); if (childnv.Name.ToUpper().Equals("SOURCE_ROUTE".ToUpper())) { sourceRoute = childnv.Atom.ToUpper().Equals("yes".ToUpper()) || childnv.Atom.ToUpper().Equals("on".ToUpper()) || childnv.Atom.ToUpper().Equals("true".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("LOAD_BALANCE".ToUpper())) { loadBalance = childnv.Atom.ToUpper().Equals("yes".ToUpper()) || childnv.Atom.ToUpper().Equals("on".ToUpper()) || childnv.Atom.ToUpper().Equals("true".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("FAILOVER".ToUpper())) { failover = childnv.Atom.ToUpper().Equals("yes".ToUpper()) || childnv.Atom.ToUpper().Equals("on".ToUpper()) || childnv.Atom.ToUpper().Equals("true".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("ENABLE".ToUpper())) { keepAlive = childnv.Atom.ToUpper().Equals("broken".ToUpper()); continue; } if (childnv.Name.ToUpper().Equals("PROTOCOL_STACK".ToUpper())) { protocolStacks.Add(childnv.ToString()); continue; } if (childnv.Name.ToUpper().Equals("ADDRESS".ToUpper())) { child = f.create(0); child.initFromNVPair(childnv); children.Add(child); continue; } if (childnv.Name.ToUpper().Equals("ADDRESS_LIST".ToUpper())) { child = f.create(1); child.initFromNVPair(childnv); children.Add(child); continue; } if (childnv.Name.ToUpper().Equals("SDU".ToUpper())) { SDU = childnv.Atom; continue; } if (childnv.Name.ToUpper().Equals("TDU".ToUpper())) { TDU = childnv.Atom; continue; } if (childnv.Name.ToUpper().Equals("SEND_BUF_SIZE".ToUpper())) { sendBufSize = childnv.Atom; continue; } if (childnv.Name.ToUpper().Equals("RECV_BUF_SIZE".ToUpper())) { receiveBufSize = childnv.Atom; continue; } if (childnv.Name.ToUpper().Equals("CONNECT_DATA".ToUpper())) { connectData = childnv.valueToString(); int k = childnv.ListSize; if (k == 0) { throw new TnsException(); } int i1 = 0; do { if (i1 >= k) { continue; } NVPair nvpair1 = childnv.getListElement(i1); if (nvpair1.Name.ToUpper().Equals("SID".ToUpper())) { SID = nvpair1.Atom; } else if (nvpair1.Name.ToUpper().Equals("SERVER".ToUpper())) { server = nvpair1.Atom; } else if (nvpair1.Name.ToUpper().Equals("SERVICE_NAME".ToUpper())) { serviceName = nvpair1.Atom; } else if (nvpair1.Name.ToUpper().Equals("INSTANCE_NAME".ToUpper())) { instanceName = nvpair1.Atom; } else if (nvpair1.Name.ToUpper().Equals("HANDLER_NAME".ToUpper())) { handlerName = nvpair1.Atom; } else if (nvpair1.Name.ToUpper().Equals("ORACLE_HOME".ToUpper())) { oracleHome = nvpair1.Atom; } else if (nvpair1.Name.ToUpper().Equals("FAILOVER_MODE".ToUpper())) { failoverMode = childnv.getListElement(i1).ToString(); } else if (nvpair1.Name.ToUpper().Equals("INSTANCE_ROLE".ToUpper())) { instanceRole = nvpair1.Atom; } else { String s1 = nvpair1.ToString().Trim(); s1 = s1.Substring(1, (s1.Length - 1) - (1)); extraConnInfo.Add(s1); } i1++; } while (true); } if (childnv.Name.ToUpper().Equals("SECURITY".ToUpper())) { int l = childnv.ListSize; if (l == 0) { throw new TnsException(); } int j1 = 0; do { if (j1 >= l) { continue; } NVPair nvpair2 = childnv.getListElement(j1); if (nvpair2.Name.ToUpper().Equals("AUTHENTICATION".ToUpper())) { authTypes = nvpair2.ToString(); } if (nvpair2.Name.ToUpper().Equals("ssl_server_cert_dn".ToUpper())) { sslServerCertDN = nvpair2.Atom; if (sslServerCertDN != null && sslServerCertDN.StartsWith("\"") && sslServerCertDN.EndsWith("\"")) { sslServerCertDN = sslServerCertDN.Substring(1, (sslServerCertDN.Length - 1) - (1)); } } else { authParams.Add(nvpair2.ToString()); } j1++; } while (true); } if (childnv.Name.ToUpper().Equals("HS".ToUpper()) && childnv.Atom == null) { try { childnv.Atom = "OK"; } catch { } } String s = childnv.ToString().Trim(); s = s.Substring(1, (s.Length - 1) - (1)); extraInfo.Add(s); } }
private void _setParent(NVPair nvpair) { _parent = nvpair; }
/// <remarks/> public String toString(int i, bool flag) { String s = ""; String s1 = new StringBuilder(_name).ToString(); if (_rhsType == RHS_LIST) { if (_listType == LIST_REGULAR) { String s2 = ""; for (int k = 0; k < ListSize; k++) { if (s1.ToUpper().Equals("ADDRESS".ToUpper()) || s1.ToUpper().Equals("RULE".ToUpper())) { s2 = s2 + getListElement(k).toString(i + 1, false); } else { s2 = s2 + getListElement(k).toString(i + 1, true); } } if (!s2.Equals("")) { if (s1.ToUpper().Equals("ADDRESS".ToUpper()) || s1.ToUpper().Equals("RULE".ToUpper())) { s = s + space(i * 2) + "(" + _name + " = "; } else { s = s + space(i * 2) + "(" + _name + " =" + _linesep; } s = s + s2; if (s1.ToUpper().Equals("ADDRESS".ToUpper()) || s1.ToUpper().Equals("RULE".ToUpper())) { s = s + ")" + _linesep; } else if (i == 0) { s = s + ")"; } else if (i == 1) { s = s + space(i * 2) + ")"; } else { s = s + space(i * 2) + ")" + _linesep; } } } else if (_listType == LIST_COMMASEP) { s = s + "(" + _name + "=" + " ("; for (int j = 0; j < ListSize; j++) { NVPair nvpair = getListElement(j); s = s + nvpair.Name; if (j != ListSize - 1) { s = s + ", "; } } s = s + ")" + ")"; } } else if (_rhsType == RHS_ATOM) { if (i == 0) { if (s1.IndexOf("COMMENT") != -1) { _atom = modifyCommentString(_atom); s = s + "(" + _atom + ")"; } else { s = s + "(" + _name + " = " + _atom + ")"; } } else if (s1.IndexOf("COMMENT") != -1) { _atom = modifyCommentString(_atom); s = s + _atom + _linesep; } else if (!flag) { s = s + "(" + _name + " = " + _atom + ")"; } else { s = s + space(i * 2) + "(" + _name + " = " + _atom + ")"; s = s + _linesep; } } return(s); }
/// <remarks/> public NVPair(String s, NVPair nvpair) : this(s) { addListElement(nvpair); }
/// <remarks/> public virtual void addNLPListElement(String s) { char[] ac = new char[s.Length + 2]; String s1; SupportClass.GetCharsFromString(s, 0, s.Length, ac, 1); if (ac[1] == '(') { s1 = s; } else { ac[0] = '('; String s2 = Environment.GetEnvironmentVariable("OS"); if (s2.Equals("Windows NT") || s2.Equals("Windows 95")) { if (ac[ac.Length - 2] == '/' || ac[ac.Length - 2] == '\\') { ac[ac.Length - 2] = ')'; } else { ac[ac.Length - 1] = ')'; } } else if (ac[ac.Length - 2] == '\\') { ac[ac.Length - 2] = ')'; } else { ac[ac.Length - 1] = ')'; } s1 = new String(ac); } NVFactory nvfactory = new NVFactory(); NVPair nvpair = nvfactory.createNVPair(s1); if (nvpair.RHSType == NVPair.RHS_NONE) { throw new TnsException("RHS nulo"); } String s3 = nvpair.Name; String s4 = s3.ToUpper(); nvpair.Name = s4; sbyte byte0 = addNLPListElement(s4, nvpair); switch (byte0) { default: break; case 2: // '\002' if (DEBUG) { Console.Out.WriteLine("The value for the Name: " + s3 + " was overwritten\n"); } break; case -1: if (DEBUG) { Console.Out.WriteLine("The value for the Name: " + s3 + " could not be inserted\n"); } break; } }