コード例 #1
0
 /// <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;
 }
コード例 #2
0
        public static void makeAll(System.String baseDirectory, System.String version)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "EventMapping");

            //get list of data types
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            System.String sql = "SELECT * from HL7EventMessageTypes inner join HL7Versions on HL7EventMessageTypes.version_id = HL7Versions.version_id where HL7Versions.hl7_version = '" + version + "'";
            System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
            temp_OleDbCommand.Connection = conn;
            temp_OleDbCommand.CommandText = sql;
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            using (StreamWriter sw = new StreamWriter(targetDir.FullName + @"\EventMap.properties", false))
            {
                sw.WriteLine("#event -> structure map for " + version);
                while (rs.Read())
                {
                    string messageType = string.Format("{0}_{1}", rs["message_typ_snd"], rs["event_code"]);
                    string structure = (string) rs["message_structure_snd"];

                    sw.WriteLine(string.Format("{0} {1}", messageType, structure));
                }
            }
        }
コード例 #3
0
		/// <summary> <p>Creates source code for a Group and returns a GroupDef object that 
		/// describes the Group's name, optionality, repeatability.  The source 
		/// code is written under the given directory.</p>  
		/// <p>The structures list may contain [] and {} pairs representing 
		/// nested groups and their optionality and repeastability.  In these cases
		/// this method is called recursively.</p>
		/// <p>If the given structures list begins and ends with repetition and/or 
		/// optionality markers the repetition and optionality of the returned 
		/// GroupDef are set accordingly.</p>  
		/// </summary>
		/// <param name="structures">a list of the structures that comprise this group - must 
		/// be at least 2 long
		/// </param>
		/// <param name="baseDirectory">the directory to which files should be written
		/// </param>
		/// <param name="message">the message to which this group belongs
		/// </param>
		/// <throws>  HL7Exception if the repetition and optionality markers are not  </throws>
		/// <summary>      properly nested.  
		/// </summary>
		public static NuGenGroupDef writeGroup(NuGenStructureDef[] structures, System.String groupName, System.String baseDirectory, System.String version, System.String message)
		{
			
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			System.IO.FileInfo targetDir = NuGenSourceGenerator.makeDirectory(baseDirectory + NuGenSourceGenerator.getVersionPackagePath(version) + "group");
			
			NuGenGroupDef group = getGroupDef(structures, groupName, baseDirectory, version, message);
			System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(new System.IO.StreamWriter(targetDir.FullName + "/" + group.Name + ".java", false, System.Text.Encoding.Default).BaseStream, new System.IO.StreamWriter(targetDir.FullName + "/" + group.Name + ".java", false, System.Text.Encoding.Default).Encoding);
			out_Renamed.Write(makePreamble(group, version));
			out_Renamed.Write(makeConstructor(group, version));
			
			NuGenStructureDef[] shallow = group.Structures;
			for (int i = 0; i < shallow.Length; i++)
			{
				out_Renamed.Write(makeAccessor(group, i));
			}
			out_Renamed.Write("}\r\n");
			out_Renamed.Flush();
			out_Renamed.Close();
			
			return group;
		}
コード例 #4
0
ファイル: Single.cs プロジェクト: Cefa68000/lucenenet
 /// <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);
 }
コード例 #5
0
ファイル: Single.cs プロジェクト: Cefa68000/lucenenet
 /// <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);
 }
コード例 #6
0
ファイル: Single.cs プロジェクト: Cefa68000/lucenenet
 /// <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));
 }
コード例 #7
0
ファイル: EndsWithTest.cs プロジェクト: RebornRider/MoreLINQ
        public void EndsWithUsesSpecifiedEqualityComparerOrDefault()
        {
            var first = new[] {1,2,3};
            var second = new[] {4,5,6};

            Assert.False(first.EndsWith(second));
            Assert.False(first.EndsWith(second, null));
            Assert.False(first.EndsWith(second, new EqualityComparerFunc<int>((f, s) => false)));
            Assert.True(first.EndsWith(second, new EqualityComparerFunc<int>((f, s) => true)));
        }
コード例 #8
0
		/// <summary> <p>Creates skeletal source code (without correct data structure but no business
		/// logic) for all data types found in the normative database.  For versions > 2.2, Primitive data types
		/// are not generated, because they are coded manually (as of HAPI 0.3).  
		/// </summary>
		public static void  makeAll(System.String baseDirectory, System.String version)
		{
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			System.IO.FileInfo targetDir = NuGenSourceGenerator.makeDirectory(baseDirectory + NuGenSourceGenerator.getVersionPackagePath(version) + "datatype");
			
			//get list of data types
			System.Collections.ArrayList types = new System.Collections.ArrayList();
			System.Data.OleDb.OleDbConnection conn = NuGenNormativeDatabase.Instance.Connection;
			System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
			//get normal data types ... 
			System.Data.OleDb.OleDbCommand temp_OleDbCommand;
			temp_OleDbCommand = stmt;
			temp_OleDbCommand.CommandText = "select data_type_code from HL7DataTypes, HL7Versions where HL7Versions.version_id = HL7DataTypes.version_id and HL7Versions.hl7_version = '" + version + "'";
			System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
			while (rs.Read())
			{
				types.Add(System.Convert.ToString(rs[1 - 1]));
			}
			
			//get CF, CK, CM, CN, CQ sub-types ... 
			
			System.Data.OleDb.OleDbCommand temp_OleDbCommand2;
			temp_OleDbCommand2 = stmt;
			temp_OleDbCommand2.CommandText = "select data_structure from HL7DataStructures, HL7Versions where (" + "data_type_code  = 'CF' or " + "data_type_code  = 'CK' or " + "data_type_code  = 'CM' or " + "data_type_code  = 'CN' or " + "data_type_code  = 'CQ') and " + "HL7Versions.version_id = HL7DataStructures.version_id and  HL7Versions.hl7_version = '" + version + "'";
			rs = temp_OleDbCommand2.ExecuteReader();
			while (rs.Read())
			{
				types.Add(System.Convert.ToString(rs[1 - 1]));
			}
			
			NuGenNormativeDatabase.Instance.returnConnection(conn);
			
			System.Console.Out.WriteLine("Generating " + types.Count + " datatypes for version " + version);
			if (types.Count == 0)
			{
			}
			
			for (int i = 0; i < types.Count; i++)
			{
				try
				{
					make(targetDir, (System.String) types[i], version);
				}
				catch (DataTypeException)
				{
				}
				catch (System.Exception)
				{
				}
			}
		}
コード例 #9
0
		/// <summary> <p>Creates skeletal source code (without correct data structure but no business
		/// logic) for all segments found in the normative database.  </p>
		/// </summary>
		public static void  makeAll(System.String baseDirectory, System.String version)
		{
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			System.IO.FileInfo targetDir = NuGenSourceGenerator.makeDirectory(baseDirectory + NuGenSourceGenerator.getVersionPackagePath(version) + "segment");
			
			//get list of data types
			System.Data.OleDb.OleDbConnection conn = NuGenNormativeDatabase.Instance.Connection;
			System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
			System.String sql = "SELECT seg_code, section from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" + version + "'";
			//System.out.println(sql);
			System.Data.OleDb.OleDbCommand temp_OleDbCommand;
			temp_OleDbCommand = stmt;
			temp_OleDbCommand.CommandText = sql;
			System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
			
			System.Collections.ArrayList segments = new System.Collections.ArrayList();
            while (rs.Read())
            {
                System.String segName = System.Convert.ToString(rs[1 - 1]);
                if (System.Char.IsLetter(segName[0]))
                    segments.Add(altSegName(segName));
            }

			NuGenNormativeDatabase.Instance.returnConnection(conn);
			
			if (segments.Count == 0)
			{
			}
			
			for (int i = 0; i < segments.Count; i++)
			{
				try
				{
					System.String seg = (System.String) segments[i];
					System.String source = makeSegment(seg, version);
					System.IO.StreamWriter w = new System.IO.StreamWriter(new System.IO.StreamWriter(targetDir.ToString() + "/" + seg + ".java", false, System.Text.Encoding.Default).BaseStream, new System.IO.StreamWriter(targetDir.ToString() + "/" + seg + ".java", false, System.Text.Encoding.Default).Encoding);
					w.Write(source);
					w.Flush();
					w.Close();
				}
				catch (System.Exception e)
				{
					System.Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
					SupportClass.WriteStackTrace(e, Console.Error);
				}
			}
		}
コード例 #10
0
ファイル: Single.cs プロジェクト: kstenson/NHibernate.Search
 /// <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;					
     }
 }
コード例 #11
0
ファイル: Single.cs プロジェクト: kstenson/NHibernate.Search
 /// <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;					
     }
 }
コード例 #12
0
 public override IndexInput OpenInput(System.String name)
 {
     IndexInput ii = base.OpenInput(name);
     if (name.EndsWith(".prx"))
     {
         // we decorate the proxStream with a wrapper class that allows to count the number of calls of seek()
         ii = new SeeksCountingStream(enclosingInstance, ii);
     }
     return ii;
 }
コード例 #13
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)
        {
            for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.Length; i++)
            {
                if (name.EndsWith("." + IndexFileNames.INDEX_EXTENSIONS[i]))
                    return true;
            }
            if (name.Equals(IndexFileNames.DELETABLE))
                return true;
            else if (name.Equals(IndexFileNames.SEGMENTS))
                return true;
            else return true; // else if (name.Matches(".+\\.f\\d+")) // {{Aroush-1.9}}

            // return false;
        }
コード例 #14
0
ファイル: IDNA.cs プロジェクト: don59/agsXmpp
		/// <summary> Converts a Unicode string to ASCII using the procedure in RFC3490
		/// section 4.1. Unassigned characters are not allowed and STD3 ASCII
		/// rules are enforced.
		/// *
		/// </summary>
		/// <param name="input">Unicode string.
		/// </param>
		/// <param name="allowUnassigned">Unassigned characters, allowed or not?
		/// </param>
		/// <param name="useSTD3ASCIIRules">STD3 ASCII rules, enforced or not?
		/// </param>
		/// <returns> Encoded string.
		/// 
		/// </returns>
		public static System.String toASCII(System.String input, bool allowUnassigned, bool useSTD3ASCIIRules)
		{
			// Step 1: Check if the string contains code points outside
			//         the ASCII range 0..0x7c.
			
			bool nonASCII = false;
			
			for (int i = 0; i < input.Length; i++)
			{
				int c = input[i];
				if (c > 0x7f)
				{
					nonASCII = true;
					break;
				}
			}
			
			// Step 2: Perform the nameprep operation.
			
			if (nonASCII)
			{
				try
				{
					input = Stringprep.nameprep(input, allowUnassigned);
				}
				catch (StringprepException e)
				{
					// TODO 
					throw new IDNAException(e);
				}
			}
			
			// Step 3: - Verify the absence of non-LDH ASCII code points
			//    (char) 0..0x2c, 0x2e..0x2f, 0x3a..0x40, 0x5b..0x60,
			//    (char) 0x7b..0x7f
			//         - Verify the absence of leading and trailing
			//           hyphen-minus
			
			if (useSTD3ASCIIRules)
			{
				for (int i = 0; i < input.Length; i++)
				{
					int c = input[i];
					if ((c <= 0x2c) || (c >= 0x2e && c <= 0x2f) || (c >= 0x3a && c <= 0x40) || (c >= 0x5b && c <= 0x60) || (c >= 0x7b && c <= 0x7f))
					{
						throw new IDNAException(IDNAException.CONTAINS_NON_LDH);
					}
				}
				
				if (input.StartsWith("-") || input.EndsWith("-"))
				{
					throw new IDNAException(IDNAException.CONTAINS_HYPHEN);
				}
			}
			
			// Step 4: If all code points are inside 0..0x7f, skip to step 8
			
			nonASCII = false;
			
			for (int i = 0; i < input.Length; i++)
			{
				int c = input[i];
				if (c > 0x7f)
				{
					nonASCII = true;
					break;
				}
			}
			
			System.String output = input;
			
			if (nonASCII)
			{
				
				// Step 5: Verify that the sequence does not begin with the ACE prefix.
				
				if (input.StartsWith(ACE_PREFIX))
				{
					throw new IDNAException(IDNAException.CONTAINS_ACE_PREFIX);
				}
				
				// Step 6: Punycode
				
				try
				{
					output = Punycode.encode(input);
				}
				catch (PunycodeException e)
				{
					// TODO
					throw new IDNAException(e);
				}
				
				// Step 7: Prepend the ACE prefix.
				
				output = ACE_PREFIX + output;
			}
			
			// Step 8: Check that the length is inside 1..63.
			
			if (output.Length < 1 || output.Length > 63)
			{
				throw new IDNAException(IDNAException.TOO_LONG);
			}
			
			return output;
		}
コード例 #15
0
ファイル: ResultsReporter.cs プロジェクト: ewcasas/DVTK
        /// <summary>
        /// Transform the XML file into HTML. Try to do both the Summary and Detailed files.
        /// </summary>
        /// <param name="directory">Results directory.</param>
        /// <param name="filename">Results filename.</param>
        /// <returns>Detailed or Summary HTML Results filename.</returns>
        public static System.String Transform(System.String directory, System.String filename)
        {
            System.String resultsFilename = System.String.Empty;

            try
            {
                // set up transformer
                XslCompiledTransform xslt = new XslCompiledTransform();
                XsltSettings settings = new XsltSettings();
                settings.EnableDocumentFunction = true;

                xslt.Load(StyleSheetFullFileName, settings, null);

                try
                {
                    // transform summary results
                    if(directory.EndsWith("\\"))
                    {
                        resultsFilename = directory + "Summary_" + filename;
                    }
                    else
                    {
                        resultsFilename = directory + "\\Summary_" + filename;
                    }

                    XmlReader reader = XmlReader.Create(resultsFilename);
                    resultsFilename = resultsFilename.Replace(".xml", ".html");
                    XmlTextWriter writer = new XmlTextWriter(resultsFilename, System.Text.Encoding.UTF8);
                    writer.Formatting = Formatting.None;
                    xslt.Transform(reader, null, writer);
                    writer.Flush();
                    writer.Close();
                    reader.Close();
                }
                catch
                {
                    // can't transform summary results - summary XML file not found
                }

                try
                {
                    // transform detailed results
                    if(directory.EndsWith("\\"))
                    {
                        resultsFilename = directory + "Detail_" + filename;
                    }
                    else
                    {
                        resultsFilename = directory + "\\Detail_" + filename;
                    }

                    XmlReader reader = XmlReader.Create(resultsFilename);
                    resultsFilename = resultsFilename.Replace(".xml", ".html");
                    XmlTextWriter writer = new XmlTextWriter(resultsFilename, System.Text.Encoding.UTF8);
                    writer.Formatting = Formatting.None;
                    xslt.Transform(reader, null, writer);
                    writer.Flush();
                    writer.Close();
                    reader.Close();
                }
                catch
                {
                    // can't transform detailed results - detailed XML file not found
                }
            }
            catch (System.Exception e)
            {
                // can't setup transformer - style sheet not found
                Console.WriteLine("XML transformation exception: {0}", e.Message);
            }

            // return the detailed results filename
            // - otherwise return the summary results
            // - otherwise return empty string
            return resultsFilename;
        }
コード例 #16
0
ファイル: GroupGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> Creates source code for a Group and returns a GroupDef object that 
        /// describes the Group's name, optionality, repeatability.  The source 
        /// code is written under the given directory.
        /// The structures list may contain [] and {} pairs representing 
        /// nested groups and their optionality and repeastability.  In these cases
        /// this method is called recursively.
        /// If the given structures list begins and ends with repetition and/or 
        /// optionality markers the repetition and optionality of the returned 
        /// GroupDef are set accordingly.  
        /// <param name="structures">a list of the structures that comprise this group - must 
        /// be at least 2 long
        /// </param>
        /// <param name="groupName">The group name</param>
        /// <param name="version">The version of message</param>
        /// <param name="baseDirectory">the directory to which files should be written
        /// </param>
        /// <param name="message">the message to which this group belongs
        /// </param>
        /// <throws>  HL7Exception if the repetition and optionality markers are not  </throws>
        /// </summary>
        public static GroupDef writeGroup(IStructureDef[] structures, System.String groupName, System.String baseDirectory, System.String version, System.String message)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Group");

            GroupDef group = getGroupDef(structures, groupName, baseDirectory, version, message);
            using (System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(targetDir.FullName + "/" + group.Name + ".cs"))
            {
                out_Renamed.Write(makePreamble(group, version));
                out_Renamed.Write(makeConstructor(group, version));

                IStructureDef[] shallow = group.Structures;
                for (int i = 0; i < shallow.Length; i++)
                {
                    out_Renamed.Write(makeAccessor(group, i));
                }
                out_Renamed.Write("}\r\n"); //Closing class
                out_Renamed.Write("}\r\n"); //Closing namespace
            }
            return group;
        }
コード例 #17
0
ファイル: DataTypeGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> <p>Creates skeletal source code (without correct data structure but no business
        /// logic) for all data types found in the normative database.  For versions > 2.2, Primitive data types
        /// are not generated, because they are coded manually (as of HAPI 0.3).  
        /// </summary>
        public static void makeAll(System.String baseDirectory, System.String version)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "datatype");
            SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "datatype");
            //get list of data types
            System.Collections.ArrayList types = new System.Collections.ArrayList();
            //UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'"
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            //UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'"
            System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
            //get normal data types ...
            //UPGRADE_TODO: Interface 'java.sql.ResultSet' was converted to 'System.Data.OleDb.OleDbDataReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlResultSet'"
            System.Data.OleDb.OleDbCommand temp_OleDbCommand;
            temp_OleDbCommand = stmt;
            temp_OleDbCommand.CommandText = "select data_type_code from HL7DataTypes, HL7Versions where HL7Versions.version_id = HL7DataTypes.version_id and HL7Versions.hl7_version = '" + version + "'";
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
            while (rs.Read())
            {
                types.Add(System.Convert.ToString(rs[1 - 1]));
            }
            rs.Close();
            //get CF, CK, CM, CN, CQ sub-types ...

            System.Data.OleDb.OleDbCommand temp_OleDbCommand2;
            temp_OleDbCommand2 = stmt;
            temp_OleDbCommand2.CommandText = "select data_structure from HL7DataStructures, HL7Versions where (" + "data_type_code  = 'CF' or " + "data_type_code  = 'CK' or " + "data_type_code  = 'CM' or " + "data_type_code  = 'CN' or " + "data_type_code  = 'CQ') and " + "HL7Versions.version_id = HL7DataStructures.version_id and  HL7Versions.hl7_version = '" + version + "'";
            rs = temp_OleDbCommand2.ExecuteReader();
            while (rs.Read())
            {
                types.Add(System.Convert.ToString(rs[1 - 1]));
            }

            //UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'"
            stmt.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            System.Console.Out.WriteLine("Generating " + types.Count + " datatypes for version " + version);
            if (types.Count == 0)
            {
                //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
                log.warn("No version " + version + " data types found in database " + conn.Database);
            }

            for (int i = 0; i < types.Count; i++)
            {
                if(!((String)types[i]).Equals("*"))
                    make(targetDir, (System.String) types[i], version);
            }
        }
コード例 #18
0
ファイル: StringUtils.cs プロジェクト: DF-thangld/web_game
        /// <summary> Chop i characters off the end of a string.
        /// A 2 character EOL will count as 1 character.
        /// *
        /// </summary>
        /// <param name="string">String to chop.
        /// </param>
        /// <param name="i">Number of characters to chop.
        /// </param>
        /// <param name="eol">A String representing the EOL (end of line).
        /// </param>
        /// <returns>String with processed answer.
        ///
        /// </returns>
        public static System.String chop(System.String s, int i, System.String eol)
        {
            if (i == 0 || s == null || eol == null) {
            return s;
            }

            int length = s.Length;

            /*
            * if it is a 2 char EOL and the string ends with
            * it, nip it off.  The EOL in this case is treated like 1 character
            */
            if (eol.Length == 2 && s.EndsWith(eol)) {
            length -= 2;
            i -= 1;
            }

            if (i > 0) {
            length -= i;
            }

            if (length < 0) {
            length = 0;
            }

            return s.Substring(0, (length) - (0));
        }
コード例 #19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static System.Single Parse(System.String s)
        {
            System.Double res;

            if (s.EndsWith("f") || s.EndsWith("F"))
            {
                System.Double.TryParse(s.Substring(0, s.Length - 1),
                    (System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands),
                    null, out res);
            }
            else
            {
                System.Double.TryParse(s,
                    (System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands),
                    null, out res);
            }

            try
            {
                return System.Convert.ToSingle(res);
            }
            catch (System.OverflowException)
            {
                return 0;
            }
        }
コード例 #20
0
ファイル: Single.cs プロジェクト: Cefa68000/lucenenet
        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;
        }
コード例 #21
0
 public void ToFriendlyTypeNameShouldReturnProperNameWhenTypeIsAnonymousWithGeneric()
 {
     var name = new { Int = 1, String = "Test" }.GetType().ToFriendlyTypeName();
     Assert.True(name.StartsWith("AnonymousType"));
     Assert.True(name.EndsWith("<Int32, String>"));
 }
コード例 #22
0
ファイル: SegmentGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> <p>Creates skeletal source code (without correct data structure but no business
        /// logic) for all segments found in the normative database.  </p>
        /// </summary>
        public static void makeAll(System.String baseDirectory, System.String version)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Segment");

            //get list of data types
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            System.String sql = "SELECT seg_code, [section] from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" + version + "'";
            System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
            temp_OleDbCommand.Connection = conn;
            temp_OleDbCommand.CommandText = sql;
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList segments = new System.Collections.ArrayList();
            while (rs.Read())
            {
                System.String segName = System.Convert.ToString(rs[1 - 1]);
                if (System.Char.IsLetter(segName[0]))
                    segments.Add(altSegName(segName));
            }
            temp_OleDbCommand.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            if (segments.Count == 0)
            {
                log.Warn("No version " + version + " segments found in database " + conn.Database);
            }

            for (int i = 0; i < segments.Count; i++)
            {
                try
                {
                    System.String seg = (System.String)segments[i];
                    System.String source = makeSegment(seg, version);
                    using (System.IO.StreamWriter w = new System.IO.StreamWriter(targetDir.ToString() + @"\" + GetSpecialFilename(seg) + ".cs"))
                    {
                        w.Write(source);
                        w.Write("}");
                    }
                }
                catch (System.Exception e)
                {
                    System.Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
                    SupportClass.WriteStackTrace(e, Console.Error);
                }
            }
        }
コード例 #23
0
ファイル: Single.cs プロジェクト: kstenson/NHibernate.Search
 /// <summary>
 /// 
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s)
 {
     try
     {
         if (s.EndsWith("f") || s.EndsWith("F"))
             return System.Single.Parse(s.Substring(0, s.Length - 1).Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
         else
             return System.Single.Parse(s.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
     }
     catch(System.FormatException fex)
     {
         throw fex;					
     }
 }
コード例 #24
0
ファイル: SegmentGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> <p>Creates skeletal source code (without correct data structure but no business
        /// logic) for all segments found in the normative database.  </p>
        /// </summary>
        public static void makeAll(System.String baseDirectory, System.String version)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "segment");

            //get list of data types
            //UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'"
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;

            //UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'"
            System.String sql = "SELECT seg_code, [section] from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" + version + "'";
            System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
            temp_OleDbCommand.Connection = conn;
            temp_OleDbCommand.CommandText = sql;
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList segments = new System.Collections.ArrayList();
            while (rs.Read())
            {
                System.String segName = System.Convert.ToString(rs[1 - 1]);
                if (System.Char.IsLetter(segName[0]))
                    segments.Add(altSegName(segName));
            }
            //UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'"
            temp_OleDbCommand.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            if (segments.Count == 0)
            {
                //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
                log.warn("No version " + version + " segments found in database " + conn.Database);
            }

            for (int i = 0; i < segments.Count; i++)
            {
                try
                {
                    System.String seg = (System.String) segments[i];
                    System.String source = makeSegment(seg, version);
                    //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
                    //UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'"
                    //UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'"
                    using(System.IO.StreamWriter w = new System.IO.StreamWriter(targetDir.ToString() + "/" + seg + ".cs"))
                    {
                        w.Write(source);
                        w.Write("}");//Ending namespace
                    }
                }
                catch (System.Exception e)
                {
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    System.Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
                    SupportClass.WriteStackTrace(e, Console.Error);
                }
            }
        }
コード例 #25
0
ファイル: MessageGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> Creates source code for a specific message structure and
        /// writes it under the specified directory.
        /// throws IllegalArgumentException if there is no message structure
        /// for this message in the normative database
        /// </summary>
        public static void make(System.String message, System.String baseDirectory, System.String chapter, System.String version)
        {
            try
            {
                SegmentDef[] segments = getSegments(message, version);
                //System.out.println("Making: " + message + " with " + segments.length + " segments (not writing message code - just groups)");

                GroupDef group = GroupGenerator.getGroupDef(segments, null, baseDirectory, version, message);
                StructureDef[] contents = group.Structures;

                //make base directory
                if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
                {
                    baseDirectory = baseDirectory + "/";
                }

                System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "message");
                System.Console.Out.WriteLine("Writing " + message + " to " + targetDir.FullName);
                //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
                //UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'"
                //UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'"
                using(System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(targetDir.FullName + "/" + message + ".cs"))
                {
                    //System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(new System.IO.StreamWriter(targetDir.FullName + "/" + message + ".java", false, System.Text.Encoding.Default).BaseStream, new System.IO.StreamWriter(targetDir.FullName + "/" + message + ".cs", false, System.Text.Encoding.Default).Encoding);
                    out_Renamed.Write(makePreamble(contents, message, chapter, version));
                    out_Renamed.Write(makeConstructor(contents, message, version));
                    for (int i = 0; i < contents.Length; i++)
                    {
                        out_Renamed.Write(GroupGenerator.makeAccessor(group, i));
                    }
                    out_Renamed.Write(makeVersion(version));
                    //add implementation of model.control interface, if any
                    //out.write(Control.getImplementation(Control.getInterfaceImplementedBy(message), version));
                    out_Renamed.Write("}\r\n");	//End class
                    out_Renamed.Write("}\r\n");	//End namespace
                    }
            }
            catch (System.Exception e)
            {
                log.error("Error while creating source code", e);

                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                log.warn("Warning: could not write source code for message structure " + message + " - " + e.GetType().FullName + ": " + e.Message);
            }
        }
コード例 #26
0
		/// <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 &#34;
							quote = '"';
							ref_Renamed = "&quot;"; // 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);
		}
コード例 #27
0
ファイル: IndexFileNames.cs プロジェクト: jhuntsman/FlexNet
		/// <summary> Returns true if the provided filename is one of the doc
		/// store files (ends with an extension in
		/// STORE_INDEX_EXTENSIONS).
		/// </summary>
		internal static bool IsDocStoreFile(System.String fileName)
		{
			if (fileName.EndsWith(COMPOUND_FILE_STORE_EXTENSION))
				return true;
			for (int i = 0; i < STORE_INDEX_EXTENSIONS.Length; i++)
				if (fileName.EndsWith(STORE_INDEX_EXTENSIONS[i]))
					return true;
			return false;
		}
コード例 #28
0
ファイル: MessageGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> Creates source code for a specific message structure and
        /// writes it under the specified directory.
        /// throws IllegalArgumentException if there is no message structure
        /// for this message in the normative database
        /// </summary>
        public static void make(System.String message, System.String baseDirectory, System.String chapter, System.String version)
        {
            try
            {
                SegmentDef[] segments = getSegments(message, version);
                //System.out.println("Making: " + message + " with " + segments.length + " segments (not writing message code - just groups)");

                GroupDef group = GroupGenerator.getGroupDef(segments, null, baseDirectory, version, message);
                IStructureDef[] contents = group.Structures;

                //make base directory
                if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
                {
                    baseDirectory = baseDirectory + "/";
                }

                System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Message");
                System.Console.Out.WriteLine("Writing " + message + " to " + targetDir.FullName);
                using (System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(targetDir.FullName + "/" + message + ".cs"))
                {
                    out_Renamed.Write(makePreamble(contents, message, chapter, version));
                    out_Renamed.Write(makeConstructor(contents, message, version));
                    for (int i = 0; i < contents.Length; i++)
                    {
                        out_Renamed.Write(GroupGenerator.makeAccessor(group, i));
                    }

                    //add implementation of model.control interface, if any
                    out_Renamed.Write("}\r\n");	//End class
                    out_Renamed.Write("}\r\n");	//End namespace
                }
            }
            catch (System.Exception e)
            {
                log.Error("Error while creating source code", e);

                log.Warn("Warning: could not write source code for message structure " + message + " - " + e.GetType().FullName + ": " + e.Message);
            }
        }
コード例 #29
0
ファイル: DebugEncoder.cs プロジェクト: heon21st/flashdevelop
		/// <summary> C: The SWD generation for fdb is... flaky, especially the way to figure out
		/// the bitmap category based on debug module names. DebugModule and DebugScript
		/// must be set with a flag indicating whether they are classes, frame actions,
		/// etc, etc, etc.
		/// 
		/// R: I don't particularly like it either and would prefer it if this stuff
		/// lived on the fdb side, not in here.
		/// </summary>
		private bool isFrameworkClass(System.String name)
		{
			bool isIt = (name.StartsWith("mx.") && name.IndexOf(":") != - 1 && name.EndsWith(".as")) || (name.IndexOf("/mx/") > - 1);
			
			return isIt;
		}
コード例 #30
0
		/// <summary> Creates source code for a specific message structure and
		/// writes it under the specified directory.
		/// throws IllegalArgumentException if there is no message structure
		/// for this message in the normative database
		/// </summary>
		public static void  make(System.String message, System.String baseDirectory, System.String chapter, System.String version)
		{
			
			try
			{
				NuGenSegmentDef[] segments = getSegments(message, version);
				//System.out.println("Making: " + message + " with " + segments.length + " segments (not writing message code - just groups)");
				
				NuGenGroupDef group = NuGenGroupGenerator.getGroupDef(segments, null, baseDirectory, version, message);
				NuGenStructureDef[] contents = group.Structures;
				
				//make base directory
				if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
				{
					baseDirectory = baseDirectory + "/";
				}
				System.IO.FileInfo targetDir = NuGenSourceGenerator.makeDirectory(baseDirectory + NuGenSourceGenerator.getVersionPackagePath(version) + "message");
				System.Console.Out.WriteLine("Writing " + message + " to " + targetDir.FullName);
				System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(new System.IO.StreamWriter(targetDir.FullName + "/" + message + ".java", false, System.Text.Encoding.Default).BaseStream, new System.IO.StreamWriter(targetDir.FullName + "/" + message + ".java", false, System.Text.Encoding.Default).Encoding);
				out_Renamed.Write(makePreamble(contents, message, chapter, version));
				out_Renamed.Write(makeConstructor(contents, message, version));
				for (int i = 0; i < contents.Length; i++)
				{
					out_Renamed.Write(NuGenGroupGenerator.makeAccessor(group, i));
				}
				
				//add implementation of model.control interface, if any
				//out.write(Control.getImplementation(Control.getInterfaceImplementedBy(message), version));            
				out_Renamed.Write("}\r\n");
				out_Renamed.Flush();
				out_Renamed.Close();
			}
			catch (System.Exception)
			{
				
			}
		}