protected internal override void  discover(System.Type clazz, System.String propertyName) {
	    try {
		Introspector introspector = rsvc.Introspector;
		property = introspector.getProperty(clazz, propertyName);
		if (property != null) {
		    if (property.PropertyType.Equals(typeof(Boolean))) {
			return ;
		    }
		}

		/*
		*  now the convenience, flip the 1st character
		*/
		propertyName = propertyName.Substring(0,1).ToUpper() + propertyName.Substring(1);
		property = introspector.getProperty(clazz, propertyName);
		if (property != null)
		    if (property.PropertyType.Equals(typeof(Boolean))) {
			return ;
		    }

		property = null;
	    } catch (System.Exception e) {
		rsvc.error("PROGRAMMER ERROR : BooleanPropertyExector() : " + e);
	    }
	}
Пример #2
0
		public static System.String escape(System.String text, NuGenEncodingCharacters encChars)
		{
			System.Text.StringBuilder result = new System.Text.StringBuilder();
			int textLength = text.Length;
			System.Collections.Hashtable esc = getEscapeSequences(encChars);
			SupportClass.SetSupport keys = new SupportClass.HashSetSupport(esc.Keys);
			System.String escChar = System.Convert.ToString(encChars.EscapeCharacter);
			int position = 0;
			while (position < textLength)
			{
				System.Collections.IEnumerator it = keys.GetEnumerator();
				bool isReplaced = false;
				while (it.MoveNext() && !isReplaced)
				{
					System.String seq = (System.String) it.Current;
					System.String val = (System.String) esc[seq];
					if (text.Substring(position, (position + 1) - (position)).Equals(val))
					{
						result.Append(seq);
						isReplaced = true;
					}
				}
				if (!isReplaced)
				{
					result.Append(text.Substring(position, ((position + 1)) - (position)));
				}
				position++;
			}
			return result.ToString();
		}
 /// <summary> Match a String against the given pattern, supporting the following simple
 /// pattern styles: "xxx*", "*xxx" and "*xxx*" matches, as well as direct equality.
 /// </summary>
 /// <param name="pattern">the pattern to match against
 /// </param>
 /// <param name="str">the String to match
 /// </param>
 /// <returns> whether the String matches the given pattern
 /// </returns>
 public static bool SimpleMatch(System.String pattern, System.String str)
 {
     if (ObjectUtils.NullSafeEquals(pattern, str) || "*".Equals(pattern))
     {
         return true;
     }
     if (pattern == null || str == null)
     {
         return false;
     }
     if (pattern.StartsWith("*") && pattern.EndsWith("*") &&
         str.IndexOf(pattern.Substring(1, (pattern.Length - 1) - (1))) != -1)
     {
         return true;
     }
     if (pattern.StartsWith("*") && str.EndsWith(pattern.Substring(1, (pattern.Length) - (1))))
     {
         return true;
     }
     if (pattern.EndsWith("*") && str.StartsWith(pattern.Substring(0, (pattern.Length - 1) - (0))))
     {
         return true;
     }
     return false;
 }
Пример #4
0
		internal static System.String Decode(System.String entity)
		{
			if (entity[entity.Length - 1] == ';')
			// remove trailing semicolon
				entity = entity.Substring(0, (entity.Length - 1) - (0));
			if (entity[1] == '#')
			{
				int start = 2;
				int radix = 10;
				if (entity[2] == 'X' || entity[2] == 'x')
				{
					start++;
					radix = 16;
				}
				System.Char c = (char) System.Convert.ToInt32(entity.Substring(start), radix);
				return c.ToString();
			}
			else
			{
				System.String s = (System.String) decoder[entity];
				if (s != null)
					return s;
				else
					return "";
			}
		}
Пример #5
0
        /// <returns> a byte array of horizontal pixels (0 = white, 1 = black) 
        /// </returns>
        public override sbyte[] encode(System.String contents)
        {
            if (contents.Length != 8)
            {
                throw new System.ArgumentException("Requested contents should be 8 digits long, but got " + contents.Length);
            }

            sbyte[] result = new sbyte[codeWidth];
            int pos = 0;

            pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, 1);

            for (int i = 0; i <= 3; i++)
            {
                int digit = System.Int32.Parse(contents.Substring(i, (i + 1) - (i)));
                pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], 0);
            }

            pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, 0);

            for (int i = 4; i <= 7; i++)
            {
                int digit = System.Int32.Parse(contents.Substring(i, (i + 1) - (i)));
                pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], 1);
            }
            pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, 1);

            return result;
        }
		private static System.String parseName(System.String name)
		{
			int comma = name.IndexOf(',');
			if (comma >= 0)
			{
				// Format may be last,first; switch it around
				return name.Substring(comma + 1) + ' ' + name.Substring(0, (comma) - (0));
			}
			return name;
		}
Пример #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="s"></param>
 /// <param name="style"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s, System.Globalization.NumberStyles style)
 {
     if (s.EndsWith("f") || s.EndsWith("F"))
         return System.Single.Parse(s.Substring(0, s.Length - 1), style);
     else
         return System.Single.Parse(s, style);
 }
Пример #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s)
 {
     if (s.EndsWith("f") || s.EndsWith("F"))
         return System.Single.Parse(s.Substring(0, s.Length - 1).Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
     else
         return System.Single.Parse(s.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
 }
Пример #9
0
		/* (non-Javadoc)
		* @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
		*/
		public virtual bool Accept(System.IO.FileInfo dir, System.String name)
		{
			int i = name.LastIndexOf((System.Char) '.');
			if (i != - 1)
			{
				System.String extension = name.Substring(1 + i);
				if (extensions.Contains(extension))
				{
					return true;
				}
				else if (extension.StartsWith("f") && (new System.Text.RegularExpressions.Regex("f\\d+")).Match(extension).Success)
				{
					return true;
				}
				else if (extension.StartsWith("s") && (new System.Text.RegularExpressions.Regex("s\\d+")).Match(extension).Success)
				{
					return true;
				}
			}
			else
			{
				if (name.Equals(IndexFileNames.DELETABLE))
					return true;
				else if (name.StartsWith(IndexFileNames.SEGMENTS))
					return true;
			}
			return false;
		}
		/// <summary> Given a string that contains HL7 messages, and possibly other junk, 
		/// returns an array of the HL7 messages.  
		/// An attempt is made to recognize segments even if there is other 
		/// content between segments, for example if a log file logs segments 
		/// individually with timestamps between them.  
		/// 
		/// </summary>
		/// <param name="theSource">a string containing HL7 messages 
		/// </param>
		/// <returns> the HL7 messages contained in theSource
		/// </returns>
        private static System.String[] getHL7Messages(System.String theSource)
        {
            System.Collections.ArrayList messages = new System.Collections.ArrayList(20);
            Match startMatch = new Regex("^MSH", RegexOptions.Multiline).Match(theSource);

            foreach (Group group in startMatch.Groups)
            {
                System.String messageExtent = getMessageExtent(theSource.Substring(group.Index), "^MSH");

                char fieldDelim = messageExtent[3];

                Match segmentMatch = Regex.Match(messageExtent, "^[A-Z]{3}\\" + fieldDelim + ".*$", RegexOptions.Multiline);

                System.Text.StringBuilder msg = new System.Text.StringBuilder();
                foreach (Group segGroup in segmentMatch.Groups)
                {
                    msg.Append(segGroup.Value.Trim());
                    msg.Append('\r');
                }

                messages.Add(msg.ToString());
            }

            String[] retVal = new String[messages.Count];
            messages.CopyTo(retVal);

            return retVal;
        }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="s"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s, System.IFormatProvider provider)
 {
     if (s.EndsWith("f") || s.EndsWith("F"))
         return System.Single.Parse(s.Substring(0, s.Length - 1), provider);
     else
         return System.Single.Parse(s, provider);
 }
Пример #12
0
		/// <summary> Sets the color range for the IDF scores
		/// 
		/// </summary>
		/// <param name="">maxScore
		/// The score (and above) displayed as maxColor (See QueryScorer.getMaxWeight 
		/// which can be used to callibrate scoring scale)
		/// </param>
		/// <param name="">minForegroundColor
		/// The hex color used for representing IDF scores of zero eg
		/// #FFFFFF (white) or null if no foreground color required
		/// </param>
		/// <param name="">maxForegroundColor
		/// The largest hex color used for representing IDF scores eg
		/// #000000 (black) or null if no foreground color required
		/// </param>
		/// <param name="">minBackgroundColor
		/// The hex color used for representing IDF scores of zero eg
		/// #FFFFFF (white) or null if no background color required
		/// </param>
		/// <param name="">maxBackgroundColor
		/// The largest hex color used for representing IDF scores eg
		/// #000000 (black) or null if no background color required
		/// </param>
		public GradientFormatter(float maxScore, System.String minForegroundColor, System.String maxForegroundColor, System.String minBackgroundColor, System.String maxBackgroundColor)
		{
			highlightForeground = (minForegroundColor != null) && (maxForegroundColor != null);
			if (highlightForeground)
			{
				if (minForegroundColor.Length != 7)
				{
					throw new System.ArgumentException("minForegroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
				}
				if (maxForegroundColor.Length != 7)
				{
					throw new System.ArgumentException("minForegroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
				}
				fgRMin = HexToInt(minForegroundColor.Substring(1, (3) - (1)));
				fgGMin = HexToInt(minForegroundColor.Substring(3, (5) - (3)));
				fgBMin = HexToInt(minForegroundColor.Substring(5, (7) - (5)));
				
				fgRMax = HexToInt(maxForegroundColor.Substring(1, (3) - (1)));
				fgGMax = HexToInt(maxForegroundColor.Substring(3, (5) - (3)));
				fgBMax = HexToInt(maxForegroundColor.Substring(5, (7) - (5)));
			}
			
			highlightBackground = (minBackgroundColor != null) && (maxBackgroundColor != null);
			if (highlightBackground)
			{
				if (minBackgroundColor.Length != 7)
				{
					throw new System.ArgumentException("minBackgroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
				}
				if (maxBackgroundColor.Length != 7)
				{
					throw new System.ArgumentException("minBackgroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
				}
				bgRMin = HexToInt(minBackgroundColor.Substring(1, (3) - (1)));
				bgGMin = HexToInt(minBackgroundColor.Substring(3, (5) - (3)));
				bgBMin = HexToInt(minBackgroundColor.Substring(5, (7) - (5)));
				
				bgRMax = HexToInt(maxBackgroundColor.Substring(1, (3) - (1)));
				bgGMax = HexToInt(maxBackgroundColor.Substring(3, (5) - (3)));
				bgBMax = HexToInt(maxBackgroundColor.Substring(5, (7) - (5)));
			}
			//        this.corpusReader = corpusReader;
			this.maxScore = maxScore;
			//        totalNumDocs = corpusReader.numDocs();
		}
Пример #13
0
 /// <summary>Utility method to return a file's extension. </summary>
 public static System.String GetExtension(System.String name)
 {
     int i = name.LastIndexOf('.');
     if (i == - 1)
     {
         return "";
     }
     return name.Substring(i + 1, (name.Length) - (i + 1));
 }
Пример #14
0
        public static System.String escape(System.String text, EncodingCharacters encChars)
        {
            //First, take all special characters and replace them with something that is garbled
            for(int i=0;i<SPECIAL_ENCODING_VALUES.Length;i++)
            {
                string specialValues = SPECIAL_ENCODING_VALUES[i];
                text = text.Replace(specialValues, EncodeSpecialCharacters(i.ToString()));
            }
            //Encode each escape character
                        System.Collections.Hashtable esc = getEscapeSequences(encChars);
            System.Text.StringBuilder result = new System.Text.StringBuilder();
            SupportClass.SetSupport keys = new SupportClass.HashSetSupport(esc.Keys);
            System.String escChar = System.Convert.ToString(encChars.EscapeCharacter);
            int position = 0;
            while (position < text.Length)
            {
                System.Collections.IEnumerator it = keys.GetEnumerator();
                bool isReplaced = false;
                while (it.MoveNext() && !isReplaced)
                {
                    System.String seq = (System.String) it.Current;
                    System.String val = (System.String) esc[seq];
                    if (text.Substring(position, 1).Equals(val))
                    {
                        result.Append(seq);
                        isReplaced = true;
                    }
                }
                if (!isReplaced)
                {
                    result.Append(text.Substring(position, 1));
                }
                position++;
            }

            //Replace each garbled entry with the correct special value
            for(int i=0;i<SPECIAL_ENCODING_VALUES.Length;i++)
            {
                string specialValues = SPECIAL_ENCODING_VALUES[i];
                result.Replace(EncodeSpecialCharacters(i.ToString()), specialValues);
            }
            return result.ToString();
        }
		/// <summary> Returns the shortest string that is semantically equivalent to a given ER7-encoded 
		/// message string.
		/// </summary>
		public static System.String standardizeER7(System.String message)
		{
			
			//make delimiter sequences (must quote with \ if not alphanumeric; can't otherwise because of regexp rules)
			char fieldDelimChar = message[3];
			System.String fieldDelim = System.Convert.ToString(fieldDelimChar);
			if (!System.Char.IsLetterOrDigit(fieldDelimChar))
				fieldDelim = "\\" + fieldDelimChar;
			
			char compSepChar = message[4];
			System.String compSep = System.Convert.ToString(compSepChar);
			if (!System.Char.IsLetterOrDigit(compSepChar))
				compSep = "\\" + compSepChar;
			
			char repSepChar = message[5];
			System.String repSep = System.Convert.ToString(repSepChar);
			if (!System.Char.IsLetterOrDigit(repSepChar))
				repSep = "\\" + repSepChar;
			
			char subSepChar = message[7];
			System.String subSep = System.Convert.ToString(subSepChar);
			if (!System.Char.IsLetterOrDigit(subSepChar))
				subSep = "\\" + subSepChar;
			
			//char space = ' ';
			
			/* Things to strip (cumulative):
			*  - all delimiters and repetition separators before end line (i.e. end segment)
			*  - repetition separators, comp and subcomp delims before new field
			*  - subcomponent delimiters before new component
			*/
            message = Regex.Replace(message, "[" + fieldDelim + compSep + repSep + subSep + "]*[\n\r]+", "\r");
            message = Regex.Replace(message, "[" + repSep + compSep + subSep + "]*" + fieldDelim, fieldDelim);
            message = Regex.Replace(message, "[" + subSep + "]*" + compSep, compSep);
			
			//Pattern endSub = Pattern.compile("[ ]*" + subSep);
			//message = endSub.matcher(message).replaceAll(String.valueOf(subSep));
			
			//handle special case of subcomp delim in encoding characters
			message = message.Substring(0, (7) - (0)) + subSepChar + message.Substring(7);
			
			return message;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="text"></param>
		/// <returns></returns>
		public static System.String RemoveTrailingBlanks(System.String text)
		{
			char ch = ' ';
			while (ch == ' ')
			{
				ch = text[text.Length - 1];
				if (ch == ' ')
					text = text.Substring(0, (text.Length - 1) - (0));
			}
			return text;
		}
Пример #17
0
	protected internal virtual void discover(System.Type clazz, System.String propertyName) {
	    /*
	    *  this is gross and linear, but it keeps it straightforward.
	    */

	    try {
		Introspector introspector = rsvc.Introspector;
		propertyUsed = propertyName;
		property = introspector.getProperty(clazz, propertyUsed);
		if (property != null) {
		    return ;
		}

		/*
		*  now the convenience, flip the 1st character
		*/
		propertyUsed = propertyName.Substring(0,1).ToUpper() + propertyName.Substring(1);
		property = introspector.getProperty(clazz, propertyUsed);
		if (property != null) {
		    return ;
		}

		propertyUsed = propertyName.Substring(0,1).ToLower() + propertyName.Substring(1);
		property = introspector.getProperty(clazz, propertyUsed);
		if (property != null) {
		    return ;
		}

		// check for a method that takes no arguments
		propertyUsed = propertyName;
		method = introspector.getMethod(clazz, propertyUsed, new Object[0]);
		if (method != null) {
		    return;
		}

		// check for a method that takes no arguments, flipping 1st character
		propertyUsed = propertyName.Substring(0,1).ToUpper() + propertyName.Substring(1);
		method = introspector.getMethod(clazz, propertyUsed, new Object[0]);
		if (method != null) {
		    return;
		}

		propertyUsed = propertyName.Substring(0,1).ToLower() + propertyName.Substring(1);
		method = introspector.getMethod(clazz, propertyUsed, new Object[0]);
		if (method != null) {
		    return;
		}
	    } catch (System.Exception e) {
		rsvc.error("PROGRAMMER ERROR : PropertyExector() : " + e);
	    }
	}
Пример #18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="s"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s, System.IFormatProvider provider)
 {
     try
     {
         if (s.EndsWith("f") || s.EndsWith("F"))
             return System.Single.Parse(s.Substring(0, s.Length - 1), provider);
         else
             return System.Single.Parse(s, provider);
     }
     catch (System.FormatException fex)
     {
         throw fex;					
     }
 }
Пример #19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="s"></param>
 /// <param name="style"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s, System.Globalization.NumberStyles style)
 {
     try
     {
         if (s.EndsWith("f") || s.EndsWith("F"))
             return System.Single.Parse(s.Substring(0, s.Length - 1), style);
         else
             return System.Single.Parse(s, style);
     }
     catch(System.FormatException fex)
     {
         throw fex;					
     }
 }
Пример #20
0
        public override sbyte[] encode(System.String contents)
        {
            if (contents.Length != 13)
            {
                throw new System.ArgumentException("Requested contents should be 13 digits long, but got " + contents.Length);
            }

            int firstDigit = System.Int32.Parse(contents.Substring(0, (1) - (0)));
            int parities = EAN13Reader.FIRST_DIGIT_ENCODINGS[firstDigit];
            sbyte[] result = new sbyte[codeWidth];
            int pos = 0;

            pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, 1);

            // See {@link #EAN13Reader} for a description of how the first digit & left bars are encoded
            for (int i = 1; i <= 6; i++)
            {
                int digit = System.Int32.Parse(contents.Substring(i, (i + 1) - (i)));
                if ((parities >> (6 - i) & 1) == 1)
                {
                    digit += 10;
                }
                pos += appendPattern(result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], 0);
            }

            pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, 0);

            for (int i = 7; i <= 12; i++)
            {
                int digit = System.Int32.Parse(contents.Substring(i, (i + 1) - (i)));
                pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], 1);
            }
            pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, 1);

            return result;
        }
Пример #21
0
		public virtual XLRTargetNode checkPrefix(System.Globalization.CultureInfo fileLocale, System.String fileId, System.Globalization.CultureInfo locale, System.String id)
		{
			XLRTargetNode t = loadNode(fileLocale, fileId, locale, id);
			if (t == null)
			{
				int sep = fileId.LastIndexOf('$');
				
				if (sep == - 1)
					sep = fileId.LastIndexOf('.');
				
				if (sep != - 1)
					t = checkPrefix(fileLocale, fileId.Substring(0, (sep) - (0)), locale, id);
			}
			return t;
		}
Пример #22
0
        /// <summary> Changes the analysis level of the KAIST morpheme tag.</summary>
        /// <param name="tag">- morpheme tag
        /// </param>
        /// <param name="level">- the analysis level
        /// </param>
        /// <returns> the morpheme tag on the analysis level
        /// </returns>
        public static System.String getKaistTagOnLevel(System.String tag, int level)
        {
            if (tag == null || level > 4 || level < 1)
            {
                return null;
            }

            int tagLen = tag.Length;
            if (tagLen > level)
            {
                return tag.Substring(0, (level) - (0)).ToUpper();
            }
            else
            {
                return tag.ToUpper();
            }
        }
Пример #23
0
		/// <summary> Parses the given String, which must contain a single traditionally encoded 
		/// message segment, into the current repetition of the message Structure 
		/// underlying this Pointer.  See Pointer static fields for return values. 
		/// </summary>
		/// <throws>  HL7Exception if there is an error during parsing  </throws>
		public override int setSegment(System.String segment, bool correctOrder)
		{
			int status = NuGenPointer.FILL_FAILED_WRONG_SEGMENT;
			
			//make sure segment is right kind
			if (segment.Substring(0, (3) - (0)).Equals(this.name))
			{
				if (correctOrder)
				{
					//make sure empty rep exists
					if (prepEmptyInstance())
					{
						try
						{
							this.parser.parse(this.currSegment, segment, this.encodingChars);
						}
						catch (NuGenHL7Exception e)
						{
							//add segment name info and re-throw
							e.SegmentName = this.name;
							throw e;
						}
						this.currSegmentFull = true;
						status = NuGenPointer.FILL_OK;
					}
					else
					{
						status = NuGenPointer.FILL_FAILED_FULL;
					}
				}
				else
				{
					status = NuGenPointer.FILL_FAILED_OUT_OF_ORDER;
				}
			}
			return status;
		}
Пример #24
0
		private ArrayList Tokenize(System.String input)
		{
			ArrayList returnVect = new ArrayList(10);
			int nextGapPos;
			for (int curPos = 0; curPos < input.Length; curPos = nextGapPos)
			{
				char ch = input[curPos];
				if (System.Char.IsWhiteSpace(ch))
					curPos++;
				nextGapPos = input.Length;
				for (int i = 0; i < "\r\n\t \x00A0".Length; i++)
				{					
					int testPos = input.IndexOf((Char) "\r\n\t \x00A0"[i], curPos);
					if (testPos < nextGapPos && testPos != - 1)
						nextGapPos = testPos;
				}
				
				System.String term = input.Substring(curPos, (nextGapPos) - (curPos));
				//if (!stopWordHandler.isWord(term))
				returnVect.Add(term);
			}
			
			return returnVect;
		}
Пример #25
0
		private static System.String generateShortName(System.String name)
		{
			System.String s = name;
			
			/* do we have a file name? */
			int dotAt = name.LastIndexOf('.');
			if (dotAt != - 1)
			{
				/* yes let's strip the directory off */
				//UPGRADE_WARNING: Method 'java.lang.String.lastIndexOf' was converted to 'System.String.LastIndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
				int lastSlashAt = name.LastIndexOf((System.Char) System.IO.Path.DirectorySeparatorChar, dotAt);
				if (lastSlashAt == - 1 && System.IO.Path.DirectorySeparatorChar == '\\')
				{
					//UPGRADE_WARNING: Method 'java.lang.String.lastIndexOf' was converted to 'System.String.LastIndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
					lastSlashAt = name.LastIndexOf('/', dotAt);
				}
				s = name.Substring(lastSlashAt + 1);
			}
			else
			{
				/* not a file name ... */
				s = name;
			}
			return s.Trim();
		}
Пример #26
0
 /// <summary> Parse the generation off the segments file name and
 /// return it.
 /// </summary>
 public static long GenerationFromSegmentsFileName(System.String fileName)
 {
     if (fileName.Equals(IndexFileNames.SEGMENTS))
     {
         return 0;
     }
     else if (fileName.StartsWith(IndexFileNames.SEGMENTS))
     {
         return SupportClass.Number.ToInt64(fileName.Substring(1 + IndexFileNames.SEGMENTS.Length));
     }
     else
     {
         throw new System.ArgumentException("fileName \"" + fileName + "\" is not a segments file");
     }
 }
Пример #27
0
        public static bool TryParse(System.String s, out float f)
        {
            bool ok = false;

            if (s.EndsWith("f") || s.EndsWith("F"))
                ok = System.Single.TryParse(s.Substring(0, s.Length - 1).Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), out f);
            else
                ok = System.Single.TryParse(s.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), out f);

            return ok;
        }
Пример #28
0
		internal static System.String[] matchPrefixedField(System.String prefix, System.String rawText, char endChar, bool trim)
		{
			System.Collections.ArrayList matches = null;
			int i = 0;
			int max = rawText.Length;
			while (i < max)
			{
				//UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
				i = rawText.IndexOf(prefix, i);
				if (i < 0)
				{
					break;
				}
				i += prefix.Length; // Skip past this prefix we found to start
				int start = i; // Found the start of a match here
				bool done = false;
				while (!done)
				{
					//UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
					i = rawText.IndexOf((System.Char) endChar, i);
					if (i < 0)
					{
						// No terminating end character? uh, done. Set i such that loop terminates and break
						i = rawText.Length;
						done = true;
					}
					else if (rawText[i - 1] == '\\')
					{
						// semicolon was escaped so continue
						i++;
					}
					else
					{
						// found a match
						if (matches == null)
						{
							matches = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(3)); // lazy init
						}
						System.String element = unescapeBackslash(rawText.Substring(start, (i) - (start)));
						if (trim)
						{
							element = element.Trim();
						}
						matches.Add(element);
						i++;
						done = true;
					}
				}
			}
			if (matches == null || (matches.Count == 0))
			{
				return null;
			}
			return toStringArray(matches);
		}
Пример #29
0
        /// <summary>
        /// Converts a System.String number to long.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static long ToInt64(System.String s)
        {
            long number = 0;
            long factor;

            // handle negative number
            if (s.StartsWith("-"))
            {
                s = s.Substring(1);
                factor = -1;
            }
            else
            {
                factor = 1;
            }

            // generate number
            for (int i = s.Length - 1; i > -1; i--)
            {
                int n = digits.IndexOf(s[i]);

                // not supporting fractional or scientific notations
                if (n < 0)
                    throw new System.ArgumentException("Invalid or unsupported character in number: " + s[i]);

                number += (n * factor);
                factor *= 36;
            }

            return number;
        }
		/// <summary> Given the name of a group element in an XML message, returns the corresponding 
		/// group class name.  This name is identical except in order to be a valid class 
		/// name, the dot character immediately following the message name is replaced with 
		/// an underscore.  For example, there is a group element called ADT_A01.INSURANCE and the 
		/// corresponding group Class is called ADT_A01_INSURANCE. 
		/// </summary>
		//    protected static String makeGroupClassName(String elementName) {
		//        return elementName.replace('.', '_');
		//    }
		
		/// <summary> Given the name of a message and a Group class, returns the corresponding group element name in an 
		/// XML-encoded message.  This is the message name and group name separated by a dot. For example, 
		/// ADT_A01.INSURANCE.
		/// 
		/// If it looks like a segment name (i.e. has 3 characters), no change is made. 
		/// </summary>
		protected internal static System.String makeGroupElementName(System.String messageName, System.String className)
		{
			System.String ret = null;
			
			if (className.Length > 4)
			{
				System.Text.StringBuilder elementName = new System.Text.StringBuilder();
				elementName.Append(messageName);
				elementName.Append('.');
				elementName.Append(className);
				ret = elementName.ToString();
			}
			else if (className.Length == 4)
			{
				ret = className.Substring(0, (3) - (0));
			}
			else
			{
				ret = className;
			}
			
			return ret;
		}