public System.String ProcessText(System.String text) { text = text.Trim(); var remoteTypograf = new ArtLebedevStudio.WebServices.Typograf(); return remoteTypograf.ProcessText (text, _entityType, _useBr, _useP, _maxNobr); }
/// <summary> /// Convert from HL7 format to Common Data Format. /// </summary> /// <param name="hl7Format">HL7 format.</param> public override void FromHl7Format(System.String hl7Format) { _uid = hl7Format.Trim(); }
/// <summary> /// Convert from DICOM format to Common Data Format. /// </summary> /// <param name="dicomFormat">DICOM format.</param> public override void FromDicomFormat(System.String dicomFormat) { _uid = dicomFormat.Trim(); }
/// <summary> Set the value of the attribute and the quote character. /// If the value is pure whitespace, assign it 'as is' and reset the /// quote character. If not, check for leading and trailing double or /// single quotes, and if found use this as the quote character and /// the inner contents of <code>value</code> as the real value. /// Otherwise, examine the string to determine if quotes are needed /// and an appropriate quote character if so. This may involve changing /// double quotes within the string to character references. /// </summary> /// <param name="value">The new value. /// </param> public virtual void SetRawValue(System.String value_Renamed) { char ch; bool needed; bool singleq; bool doubleq; System.String ref_Renamed; System.Text.StringBuilder buffer; char quote; quote = (char) (0); if ((null != value_Renamed) && (0 != value_Renamed.Trim().Length)) { if (value_Renamed.StartsWith("'") && value_Renamed.EndsWith("'") && (2 <= value_Renamed.Length)) { quote = '\''; value_Renamed = value_Renamed.Substring(1, (value_Renamed.Length - 1) - (1)); } else if (value_Renamed.StartsWith("\"") && value_Renamed.EndsWith("\"") && (2 <= value_Renamed.Length)) { quote = '"'; value_Renamed = value_Renamed.Substring(1, (value_Renamed.Length - 1) - (1)); } else { // first determine if there's whitespace in the value // and while we're at it find a suitable quote character needed = false; singleq = true; doubleq = true; for (int i = 0; i < value_Renamed.Length; i++) { ch = value_Renamed[i]; if ('\'' == ch) { singleq = false; needed = true; } else if ('"' == ch) { doubleq = false; needed = true; } else if (!('-' == ch) && !('.' == ch) && !('_' == ch) && !(':' == ch) && !System.Char.IsLetterOrDigit(ch)) { needed = true; } } // now apply quoting if (needed) { if (doubleq) quote = '"'; else if (singleq) quote = '\''; else { // uh-oh, we need to convert some quotes into character // references, so convert all double quotes into " quote = '"'; ref_Renamed = """; // Translate.encode (quote); // JDK 1.4: value = value.replaceAll ("\"", ref); buffer = new System.Text.StringBuilder(value_Renamed.Length * (ref_Renamed.Length - 1)); for (int i = 0; i < value_Renamed.Length; i++) { ch = value_Renamed[i]; if (quote == ch) buffer.Append(ref_Renamed); else buffer.Append(ch); } value_Renamed = buffer.ToString(); } } } } SetValue(value_Renamed); SetQuote(quote); }
/// <summary> Create a whitespace attribute with the value given.</summary> /// <param name="value">The value of this attribute. /// </param> /// <exception cref="IllegalArgumentException">if the value contains other than /// whitespace. To set a real value use {@link #Attribute(String,String)}. /// </exception> public TagAttribute(System.String value_Renamed) { if (0 != value_Renamed.Trim().Length) throw new System.ArgumentException("non whitespace value"); else { SetName(null); SetAssignment(null); SetValue(value_Renamed); SetQuote((char) 0); } }
private void processAtomLoopBlock(System.String firstLine) { int atomLabel = -1; // -1 means not found in this block int atomSymbol = -1; int atomFractX = -1; int atomFractY = -1; int atomFractZ = -1; int atomRealX = -1; int atomRealY = -1; int atomRealZ = -1; System.String line = firstLine.Trim(); int headerCount = 0; bool hasParsableInformation = false; while (line != null && line[0] == '_') { headerCount++; if (line.Equals("_atom_site_label") || line.Equals("_atom_site_label_atom_id")) { atomLabel = headerCount; hasParsableInformation = true; //logger.info("label found in col: " + atomLabel); } else if (line.StartsWith("_atom_site_fract_x")) { atomFractX = headerCount; hasParsableInformation = true; //logger.info("frac x found in col: " + atomFractX); } else if (line.StartsWith("_atom_site_fract_y")) { atomFractY = headerCount; hasParsableInformation = true; //logger.info("frac y found in col: " + atomFractY); } else if (line.StartsWith("_atom_site_fract_z")) { atomFractZ = headerCount; hasParsableInformation = true; //logger.info("frac z found in col: " + atomFractZ); } else if (line.Equals("_atom_site.Cartn_x")) { atomRealX = headerCount; hasParsableInformation = true; //logger.info("cart x found in col: " + atomRealX); } else if (line.Equals("_atom_site.Cartn_y")) { atomRealY = headerCount; hasParsableInformation = true; //logger.info("cart y found in col: " + atomRealY); } else if (line.Equals("_atom_site.Cartn_z")) { atomRealZ = headerCount; hasParsableInformation = true; //logger.info("cart z found in col: " + atomRealZ); } else if (line.Equals("_atom_site.type_symbol")) { atomSymbol = headerCount; hasParsableInformation = true; //logger.info("type_symbol found in col: " + atomSymbol); } else { //logger.warn("Ignoring atom loop block field: " + line); } line = input.ReadLine().Trim(); } if (hasParsableInformation == false) { //logger.info("No parsable info found"); skipUntilEmptyOrCommentLine(line); } else { // now that headers are parsed, read the data while (line != null && line.Length > 0 && line[0] != '#') { //logger.debug("new row"); SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(line); if (tokenizer.Count < headerCount) { //logger.warn("Column count mismatch; assuming continued on next line"); //logger.debug("Found #expected, #found: " + headerCount + ", " + tokenizer.Count); tokenizer = new SupportClass.Tokenizer(line + input.ReadLine()); } int colIndex = 0; // process one row IAtom atom = crystal.Builder.newAtom("C"); Point3d frac = new Point3d(); Point3d real = new Point3d(); bool hasFractional = false; bool hasCartesian = false; while (tokenizer.HasMoreTokens()) { colIndex++; System.String field = tokenizer.NextToken(); //logger.debug("Parsing col,token: " + colIndex + "=" + field); if (colIndex == atomLabel) { if (atomSymbol == -1) { // no atom symbol found, use label System.String element = extractFirstLetters(field); atom.Symbol = element; } atom.ID = field; } else if (colIndex == atomFractX) { hasFractional = true; frac.x = parseIntoDouble(field); } else if (colIndex == atomFractY) { hasFractional = true; frac.y = parseIntoDouble(field); } else if (colIndex == atomFractZ) { hasFractional = true; frac.z = parseIntoDouble(field); } else if (colIndex == atomSymbol) { atom.Symbol = field; } else if (colIndex == atomRealX) { hasCartesian = true; //logger.debug("Adding x3: " + parseIntoDouble(field)); real.x = parseIntoDouble(field); } else if (colIndex == atomRealY) { hasCartesian = true; //logger.debug("Adding y3: " + parseIntoDouble(field)); real.y = parseIntoDouble(field); } else if (colIndex == atomRealZ) { hasCartesian = true; //logger.debug("Adding x3: " + parseIntoDouble(field)); real.z = parseIntoDouble(field); } } if (hasCartesian) { Vector3d a = crystal.A; Vector3d b = crystal.B; Vector3d c = crystal.C; frac = CrystalGeometryTools.cartesianToFractional(a, b, c, real); atom.setFractionalPoint3d(frac); } if (hasFractional) { atom.setFractionalPoint3d(frac); } //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.debug("Adding atom: " + atom); crystal.addAtom(atom); // look up next row line = input.ReadLine().Trim(); } } }
public virtual LdapResponseQueue Bind(int version, System.String dn, sbyte[] passwd, LdapResponseQueue queue, LdapConstraints cons) { int msgId; BindProperties bindProps; if (cons == null) cons = defSearchCons; if ((System.Object) dn == null) { dn = ""; } else { dn = dn.Trim(); } if (passwd == null) passwd = new sbyte[]{}; bool anonymous = false; if (passwd.Length == 0) { anonymous = true; // anonymous, passwd length zero with simple bind dn = ""; // set to null if anonymous } LdapMessage msg = new LdapBindRequest(version, dn, passwd, cons.getControls()); msgId = msg.MessageID; bindProps = new BindProperties(version, dn, "simple", anonymous, null, null); // For bind requests, if not connected, attempt to reconnect if (!conn.Connected) { if ((System.Object) conn.Host != null) { conn.connect(conn.Host, conn.Port); } else { throw new LdapException(ExceptionMessages.CONNECTION_IMPOSSIBLE, LdapException.CONNECT_ERROR, null); } } // The semaphore is released when the bind response is queued. conn.acquireWriteSemaphore(msgId); return SendRequestToServer(msg, cons.TimeLimit, queue, bindProps); }
virtual protected System.String init(System.String input, System.Boolean cc_on) { System.Char c; System.Text.StringBuilder output = new System.Text.StringBuilder(); input = System.Text.RegularExpressions.Regex.Replace(input.Trim(), "(\\s)+", MyMin.SPACE.ToString()); for (System.Int32 i = 0, l = input.Length; i < l; i++) { c = input[i]; switch (c) { case MyMin.SPACE: if (++i < l) { if (this.action(input[i])) { if (-1 < (i - 2)) { if (this.action(input[i - 2])) output.Append(c); } else output.Append(c); }; --i; }; break; case '/': if (++i < l) { c = input[i]; if (c == '*') { if (++i < l) { l = input.IndexOf("*/", i); if (-1 < l) { i = l + 2; l = input.Length; if (i < l) { --i; input = System.String.Format("{0};{1}", input.Substring(0, i), input.Substring(i + 1)); } } else throw new MyMinException("Unterminated comment."); } else throw new MyMinException("Unterminated comment."); } else output.Append(input[--i]); }; break; default: output.Append(c); break; } } return output.ToString().TrimEnd(); }
/// <summary> /// Method executes when a control point invokes the ContentDirectory.Search action. /// The method will recursively search all descendent objects and determine if /// the objects match the search criteria. All objects that match the search /// criteria will be included in a flat DIDL-Lite listing of media objects /// in the response. Sort criteria and filter criteria are just applied in /// the same manner as a browse request. /// </summary> /// <param name="containerID">Container to search from.</param> /// <param name="searchCriteria">Valid CDS search criteria string.</param> /// <param name="filter"> /// Comma separated value list of metadata property names to include in the response. /// Return * for all metadata. /// </param> /// <param name="startingIndex">Given the entire possible response set, return a subset beginning with this index in the result set.</param> /// <param name="requestedCount">Given the entire possible response set, return a subset totalling no more than this many.</param> /// <param name="sortCriteria">Specify a comma-separated value list of metadata properties, with a + or - char before each property name to indicate ascending/descending order.</param> /// <param name="Result">DIDL-Lite response for desired result set.</param> /// <param name="numberReturned">Number of media objects returned in the response. 0 if browsing object metadata.</param> /// <param name="totalMatches">Total number of media objects in entire result set. 0 if browsing object metadata.</param> /// <param name="updateID">The UpdateID of the object - ignore if an object.item entry. Applies only to object.container entries.</param> private void SinkCd_Search(System.String containerID, System.String searchCriteria, System.String filter, System.UInt32 startingIndex, System.UInt32 requestedCount, System.String sortCriteria, out System.String Result, out System.UInt32 numberReturned, out System.UInt32 totalMatches, out System.UInt32 updateID) { try { numberReturned = 0; Result = ""; totalMatches = 0; updateID = 0; // Get the container with the ID. // IDvMedia entry = this.GetCdsEntry(containerID); if (entry.IsContainer == false) { throw new Error_NoSuchContainer("("+containerID+")"); } DvMediaContainer container = (DvMediaContainer) entry; // Issue a search from the container. // Search requires a MediaComparer to determine whether an entry matches // against the searchCriteria. // Sorting is optional, but it requires that we traverse the entire subtree // in order to reply properly. // IList entries; if (sortCriteria.Trim() == "") { MediaComparer postfix = new MediaComparer(searchCriteria); entries = container.Search(postfix, startingIndex, requestedCount, out totalMatches); } else { MediaSorter sorter = new MediaSorter(true, sortCriteria); MediaComparer postfix = new MediaComparer(searchCriteria); entries = container.SearchSorted(postfix, sorter, startingIndex, requestedCount, out totalMatches); } for (int rem=0; rem < startingIndex; rem++) { entries.RemoveAt(0); } numberReturned = Convert.ToUInt32(entries.Count); updateID = container.UpdateID; // Get the XML response for this result set. // Be sure to grab the list of base URLs. ArrayList properties = GetFilters(filter); string[] baseUrls = GetBaseUrlsByInterfaces(); Result = BuildXmlRepresentation(baseUrls, properties, entries); } catch (Exception e) { Exception ne = new Exception("MediaServer.SinkCd_Search()", e); throw ne; } this.m_Stats.Search++; this.FireStatsChange(); }
virtual protected void init(System.String input, System.Boolean cc_on) { this.input = System.Text.RegularExpressions.Regex.Replace(input.Trim(), "(\n\r|\r\n|\r|\n)+", MyMin.LF.ToString()); this.input = System.Text.RegularExpressions.Regex.Replace(this.input.Trim(), "(\\\\\n)+", "");//有问题,修改之 this.length = this.input.Length; this.cc_on = cc_on; this.a = MyMin.LF; this.action(3); while (this.a != MyMin.EOS) { switch (this.a) { case MyMin.SPACE: this.action(this.isAlNum(this.b) ? 1 : 2); break; case MyMin.LF: switch (this.b) { case '{': case '[': case '(': case '+': case '-': this.action(1); break; case MyMin.SPACE: this.action(3); break; default: this.action(this.isAlNum(this.b) ? 1 : 2); break; } break; default: switch (this.b) { case MyMin.SPACE: this.action(this.isAlNum(this.a) ? 1 : 3); break; case MyMin.LF: switch (this.a) { case '}': case ']': case ')': case '+': case '-': case '"': case '\'': this.action(1); break; default: this.action(this.isAlNum(this.a) ? 1 : 3); break; } break; default: this.action(1); break; } break; } } }
/// <summary> /// Method executes when a control point invokes the ContentDirectory.Browse action. /// Depending on the input parameters, the method either returns the metadata /// for the specified object, or the method returns the metadata of all child objects /// if direct children metadata was requested and the specified object is actually /// a container. /// </summary> /// <param name="objectID">Browse the metadata or the children of this object</param> /// <param name="browseFlag">Indicate whether metadata or child object metadata is desired</param> /// <param name="filter">Comma separated value list of metadata properties indicates desired metadata properties to include in response, use * for all.</param> /// <param name="startingIndex">Given the entire possible response set, return a subset beginning with this index in the result set.</param> /// <param name="requestedCount">Given the entire possible response set, return a subset totalling no more than this many.</param> /// <param name="sortCriteria">Specify a comma-separated value list of metadata properties, with a + or - char before each property name to indicate ascending/descending order.</param> /// <param name="Result">DIDL-Lite response for desired result set.</param> /// <param name="numberReturned">Number of media objects returned in the response. 0 if browsing object metadata.</param> /// <param name="totalMatches">Total number of media objects in entire result set. 0 if browsing object metadata.</param> /// <param name="updateID">The UpdateID of the object - ignore if an object.item entry. Applies only to object.container entries.</param> private void SinkCd_Browse(System.String objectID, DvContentDirectory.Enum_A_ARG_TYPE_BrowseFlag browseFlag, System.String filter, System.UInt32 startingIndex, System.UInt32 requestedCount, System.String sortCriteria, out System.String Result, out System.UInt32 numberReturned, out System.UInt32 totalMatches, out System.UInt32 updateID) { try { numberReturned = 0; Result = ""; totalMatches = 0; if (requestedCount == 0) { requestedCount = Convert.ToUInt32(int.MaxValue); } // Get the item identified by the ID, or throw an exception // if the item doesn't exist. // IDvMedia entry = this.GetCdsEntry(objectID); // Issue a browse on the entry if it's a container and we're browing children. // Return the results in entries. Apply sorting if appropriate. // IList entries; if ((entry.IsContainer) && (browseFlag == DvContentDirectory.Enum_A_ARG_TYPE_BrowseFlag.BROWSEDIRECTCHILDREN)) { DvMediaContainer container = (DvMediaContainer) entry; if (sortCriteria.Trim() == "") { entries = container.Browse(startingIndex, requestedCount, out totalMatches); } else { MediaSorter sorter = new MediaSorter(true, sortCriteria); entries = container.BrowseSorted(startingIndex, requestedCount, sorter, out totalMatches); } numberReturned = Convert.ToUInt32(entries.Count); updateID = container.UpdateID; } else { // We're browsing an item or a container's metadata, so simply set the entry to be // the only return value. // entries = new ArrayList(); entries.Add(entry); totalMatches = 1; numberReturned = 1; IDvMedia dvMedia = (IDvMedia) entry; DvMediaContainer container = dvMedia as DvMediaContainer; if (container == null) { container = (DvMediaContainer) dvMedia.Parent; } updateID = container.UpdateID; } // Get the XML response for this result set. // Be sure to grab the list of base URLs. ArrayList properties = GetFilters(filter); string[] baseUrls = GetBaseUrlsByInterfaces(); Result = BuildXmlRepresentation(baseUrls, properties, entries); } catch (Exception e) { Exception ne = new Exception("MediaServerDevice.SinkCd_Browse()", e); throw ne; } this.m_Stats.Browse++; this.FireStatsChange(); }
/// <summary> Parse the specified selector.</summary> /// <param name="selector">Selector. /// </param> /// <param name="trace">Flag to enable/disable tracing. /// </param> /// <returns> Returns the parse state. The parse state consists of the root /// of the parse tree and the identifiers encountered during the parse. /// </returns> public static SelectorParseState doParse(System.String selector, bool trace) { try { if (selector == null) throw new System.NullReferenceException("NULL selector"); else if (selector.Trim().Length == 0) throw new System.ArgumentException("Empty selector"); return new SelectorParser().parse(selector, trace); } catch (ParseException ex) { throw new InvalidSelectorException(ex); } }
public System.String ShowAllActiveLanguage(System.Boolean showAllOpt, System.String bgColor, System.String OnChangeEvt, System.String SelLang, bool showOnlySiteEnabled) { StringBuilder result = new StringBuilder(); LanguageData[] language_data; SiteAPI m_refSiteApi = new SiteAPI(); int LanguageId = m_refSiteApi.ContentLanguage; try { if (OnChangeEvt == "") { OnChangeEvt = "SelLanguage(this.value)"; } if (SelLang.Trim() != "") { LanguageId = Convert.ToInt32(SelLang); } language_data = m_refSiteApi.GetAllActiveLanguages(); result = new StringBuilder(); if (m_refAPI.EnableMultilingual == 1) { result.Append("<select id=\"frm_langID\" name=\"frm_langID\" OnChange=\"" + OnChangeEvt + "\">" + "\r\n"); if (showAllOpt) { result.Append("<option value=\"" + Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES + "\""); if (LanguageId == Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES) { result.Append(" selected=\"selected\""); } result.Append(">"); result.Append("All"); result.Append("</option>"); } if (!(language_data == null)) { foreach (LanguageData lang in language_data) { result.Append(AddLanguageOption(lang, LanguageId, showOnlySiteEnabled)); } } result.Append("</select>"); } } catch (Exception) { result.Length = 0; } return (result.ToString()); }
public virtual LdapResponseQueue Bind(int version, System.String dn, sbyte[] passwd, LdapResponseQueue queue, LdapConstraints cons, string mech) { int msgId; BindProperties bindProps; if (cons == null) cons = defSearchCons; if ((System.Object) dn == null) { dn = ""; } else { dn = dn.Trim(); } if (passwd == null) passwd = new sbyte[]{}; bool anonymous = false; if (passwd.Length == 0) { anonymous = true; // anonymous, passwd length zero with simple bind dn = ""; // set to null if anonymous } LdapMessage msg; #if TARGET_JVM if (mech != null) msg = new LdapBindRequest(version, "", mech, passwd, cons.getControls()); else #endif msg = new LdapBindRequest(version, dn, passwd, cons.getControls()); msgId = msg.MessageID; bindProps = new BindProperties(version, dn, "simple", anonymous, null, null); // For bind requests, if not connected, attempt to reconnect if (!conn.Connected) { if ((System.Object) conn.Host != null) { conn.connect(conn.Host, conn.Port); } else { throw new LdapException(ExceptionMessages.CONNECTION_IMPOSSIBLE, LdapException.CONNECT_ERROR, null); } } #if TARGET_JVM // stopping reader to enable stream replace after secure binding is complete, see Connection.ReplaceStreams() if (mech != null) { if (conn.BindSemIdClear) { // need to acquire a semaphore only if bindSemId is clear // because if we receive SASL_BIND_IN_PROGRESS the semaphore is not // released when the response is queued conn.acquireWriteSemaphore(msgId); conn.BindSemId = msgId; } conn.stopReaderOnReply(msgId); } else #endif // The semaphore is released when the bind response is queued. conn.acquireWriteSemaphore(msgId); return SendRequestToServer(msg, cons.TimeLimit, queue, bindProps); }
/// <summary> Removes all unecessary whitespace from the given String (intended to be used with Primitive values). /// This includes leading and trailing whitespace, and repeated space characters. Carriage returns, /// line feeds, and tabs are replaced with spaces. /// </summary> protected internal virtual System.String removeWhitespace(System.String s) { s = s.Replace('\r', ' '); s = s.Replace('\n', ' '); s = s.Replace('\t', ' '); bool repeatedSpacesExist = true; while (repeatedSpacesExist) { int loc = s.IndexOf(" "); if (loc < 0) { repeatedSpacesExist = false; } else { System.Text.StringBuilder buf = new System.Text.StringBuilder(); buf.Append(s.Substring(0, (loc) - (0))); buf.Append(" "); buf.Append(s.Substring(loc + 2)); s = buf.ToString(); } } return s.Trim(); }
/// <summary> /// Remove rfc 2822 comments /// </summary> /// <param name="fieldValue"><c>string</c> to uncomment</param> /// <returns></returns> // TODO: refactorize this public static System.String uncommentString( System.String fieldValue ) { if ( fieldValue==null || fieldValue.Equals(System.String.Empty) ) return fieldValue; if ( fieldValue.IndexOf('(')==-1 ) return fieldValue.Trim(); const int a = 0; const int b = 1; const int c = 2; System.Text.StringBuilder buf = new System.Text.StringBuilder(); int leftSqureCount = 0; bool isQuotedPair = false; int state = a; for (int i = 0; i < fieldValue.Length; i ++) { switch (state) { case a: if (fieldValue[i] == '"') { state = c; System.Diagnostics.Debug.Assert(!isQuotedPair, "quoted-pair"); } else if (fieldValue[i] == '(') { state = b; leftSqureCount ++; System.Diagnostics.Debug.Assert(!isQuotedPair, "quoted-pair"); } break; case b: if (!isQuotedPair) { if (fieldValue[i] == '(') leftSqureCount ++; else if (fieldValue[i] == ')') { leftSqureCount --; if (leftSqureCount == 0) { buf.Append(' '); state = a; continue; } } } break; case c: if (!isQuotedPair) { if (fieldValue[i] == '"') state = a; } break; default: break; } if (state != a) { //quoted-pair if (isQuotedPair) isQuotedPair = false; else isQuotedPair = fieldValue[i] == '\\'; } if (state != b) buf.Append(fieldValue[i]); } return buf.ToString().Trim(); }
/// <summary> Formats a String to fit into the connectiontable. /// /// </summary> /// <param name="s"> The String to be formated /// </param> /// <param name="le"> The length of the String /// </param> /// <returns> The String to be written in the connectiontable /// </returns> private System.String formatMDLString(System.String s, int le) { s = s.Trim(); if (s.Length > le) return s.Substring(0, (le) - (0)); int l; l = le - s.Length; for (int f = 0; f < l; f++) s += " "; return s; }