Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 81/1413 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • Store comparison in variable (or execute comparison when it's given as an string)

    - by BorrajaX
    Hello everyone. I'd like to know if the super-powerful python allows to store a comparison in a variable or, if not, if it's possible calling/executing a comparison when given as an string ("==" or "!=") I want to allow the users of my program the chance of giving a comparison in an string. For instance, let's say I have a list of... "products" and the user wants to select the products whose manufacturer is "foo". He could would input something like: Product.manufacturer == "foo" and if the user wants the products whose manufacturer is not "bar" he would input Product.manufacturer != "bar" If the user inputs that line as an string, I create a tree with an structure like: != / \ manufacturer bar I'd like to allow that comparison to run properly, but I don't know how to make it happen if != is an string. The "manufacturer" field is a property, so I can properly get it from the Product class and store it (as a property) in the leaf, and well... "bar" is just an string. I'd like to know if I can something similar to what I do with "manufacturer": storing it with a 'callable" (kind of) thing: the property with the comparator: != I have tried with "eval" and it may work, but the comparisons are going to be actually used to query a MySQL database (using sqlalchemy) and I'm a bit concerned about the security of that... Any idea will be deeply appreciated. Thank you! PS: The idea of all this is being able to generate a sqlalchemy query, so if the user inputs the string: Product.manufacturer != "foo" || Product.manufacturer != "bar" ... my tree thing can generate the following: sqlalchemy.or_(Product.manufacturer !="foo", Product.manufacturer !="bar") Since sqlalchemy.or_ is callable, I can also store it in one of the leaves... I only see a problem with the "!="

    Read the article

  • Parsing and getting specific values from CSV string

    - by Amit Ranjan
    I am having a string in CSV format. Please see my earlier question http://stackoverflow.com/questions/2865861/parsing-csv-string-and-binding-it-to-listbox I can add new values to it by some mechanism. Everything will be same except the new values will have numeric part = 0. Take example I have this exsiting CSV string 1 , abc.txt , 2 , def.doc , 3 , flyaway.txt Now by some mechanism i added two more files Superman.txt and Spiderman.txt to the existing string. Now it became 1 , abc.txt , 2 , def.doc , 3 , flyaway.txt, 0, Superman.txt, 0 , Spiderman.txt What i am doing here is that this csv string is paased into SP where its splitted and inserted to db. So for inserting I have to take the files with numeric part 0 only rest will be omiited .Which will be further then converted into CSV string Array will look like this str[0]="1" str[1]="abc.txt" str[2]="2" str[3]="def.doc " str[4]="3" str[5]="flyaway.txt" str[6]="0" str[7]="Superman.txt" str[8]="0" str[9]="Spiderman.txt" So at last i want to say my input will be 1 , abc.txt , 2 , def.doc , 3 , flyaway.txt, 0, Superman.txt, 0 , Spiderman.txt Desired Output: 0, Superman.txt, 0 , Spiderman.txt

    Read the article

  • Why is Collection<String>.class Illegal?

    - by Peter
    I am puzzled by generics. You can declare a field like: Class<Collection<String>> clazz = ... It seems logical that you could assign this field with: Class<Collection<String>> clazz = Collection<String>.class; However, this generates an error: Syntax error on token ">", void expected after this token So it looks like the .class operator does not work with generics. So I tried: class A<S> {} class B extends A<String> {} Class<A<String>> c = B.class; Also does not work, generates: Type mismatch: cannot convert from Class<Test.StringCollection> to Class<Collection<String>> Now, I really fail to see why this should not work. I know generic types are not reified but in both cases it seems to be fully type safe without having access to runtime generic types. Anybody an idea? Peter Kriens

    Read the article

  • How do I import and call unmanaged C dll with ansi string "char *" pointer string from VB.net?

    - by Warren P
    I have written my own function, which in C would be declared like this, using standard Win32 calling conventions: int Thing( char * command, char * buffer, int * BufSize); I have the following amount of VB figured out, which should import the dll and call this function, wrapping it up to make it easy to call Thing("CommandHere",GetDataBackHere): Imports Microsoft.VisualBasic Imports System.Runtime.InteropServices Imports System Imports System.Text Namespace dllInvocationSpace Public Class dllInvoker ' tried attributes but could not make it build: ' <DllImport("Thing1.dll", False, CallingConvention.Cdecl, CharSet.Ansi, "Baton", True, True, False, True)> Declare Ansi Function Thing Lib "Thing1.dll" (ByVal Command As String, ByRef Buffer As String, ByRef BufferLength As Integer) Shared Function dllCall(ByVal Command As String, ByRef Results As String) As Integer Dim Buffer As StringBuilder = New StringBuilder(65536) Dim retCode As Integer Dim bufsz As Integer bufsz = 65536 retCode = Thing(Command, Buffer, bufsz) Results = Buffer Return retCode End Function End Class End Namespace The current code doesn't build, because although I think I should be able to create a "buffer" that the C Dll can write data back into using a string builder, I haven't got it quite right. (Value of type System.Text.STringBuilder cannot be converted to 'String'). I have looked all over the newsgroups and forums and can not find an example where the C dll needs to pass between 1 and 64kbytes of data back (char *buffer, int bufferlen) to visual basic.net.

    Read the article

  • Problem in encoding and decoding the string in Iphone sdk

    - by monish
    HI Guys, Here I am having a problem In encoding/decoding the strings. Actually I had a string which I am encoding it using the base64.which was working fine. And now I need to decode the string that was encoded before and want to print it. I code I written as: I imported the base64.h and base64.m files into my application which contains the methods as: + (NSData *) dataWithBase64EncodedString:(NSString *) string; - (id) initWithBase64EncodedString:(NSString *) string; - (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; And the code in my view controller where I encode the String is: - (id)init { if (self = [super init]) { // Custom initialization userName = @"Sekhar"; password = @"Bethalam"; } return self; } -(void)reloadView { NSString *authStr = [NSString stringWithFormat:@"%@:%@",userName,password]; NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; NSString *authValue = [NSString stringWithFormat:@"%@", [authData base64EncodingWithLineLength:30]]; NSLog(authValue); //const char *str = authValue; //NSString *decStr = [StringEncryption DecryptString:authValue]; //NSLog(decStr); //NSData *decodeData = [NSData decode:authValue]; //NSString *decStr = [NSString stringWithFormat:@"%@",decodeData]; //NSStr //NSLog(decStr); } -(void)viewWillAppear:(BOOL)animated { [self reloadView]; } and now I want to decode the String that I encoded. But I dont know How to do that.can anyone suggest me with code how to get it. Anyone's help will be much appreciated. Thank you, Monish.

    Read the article

  • XamlReader.Parse throws exception on empty String

    - by sub-jp
    In our app, we need to save properties of objects to the same database table regardless of the type of object, in the form of propertyName, propertyValue, propertyType. We decided to use XamlWriter to save all of the given object's properties. We then use XamlReader to load up the XAML that was created, and turn it back into the value for the property. This works fine for the most part, except for empty strings. The XamlWriter will save an empty string as below. <String xmlns="clr-namespace:System;assembly=mscorlib" xml:space="preserve" /> The XamlReader sees this string and tries to create a string, but can't find an empty constructor in the String object to use, so it throws a ParserException. The only workaround that I can think of is to not actually save the property if it is an empty string. Then, as I load up the properties, I can check for which ones did not exist, which means they would have been empty strings. Is there some workaround for this, or is there even a better way of doing this?

    Read the article

  • Capture data read from file into string stream Java

    - by halluc1nati0n
    I'm coming from a C++ background, so be kind on my n00bish queries... I'd like to read data from an input file and store it in a stringstream. I can accomplish this in an easy way in C++ using stringstreams. I'm a bit lost trying to do the same in Java. Following is a crude code/way I've developed where I'm storing the data read line-by-line in a string array. I need to use a string stream to capture my data into (rather than use a string array).. Any help? char dataCharArray[] = new char[2]; int marker=0; String inputLine; String temp_to_write_data[] = new String[100]; // Now, read from output_x into stringstream FileInputStream fstream = new FileInputStream("output_" + dataCharArray[0]); // Convert our input stream to a BufferedReader BufferedReader in = new BufferedReader (new InputStreamReader(fstream)); // Continue to read lines while there are still some left to read while ((inputLine = in.readLine()) != null ) { // Print file line to screen // System.out.println (inputLine); temp_to_write_data[marker] = inputLine; marker++; }

    Read the article

  • Input string was not in correct format

    - by Luke
    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace measurementConverter { class Program { static void Main(string[] args) { //read in the file StreamReader convert = new StreamReader("../../convert.txt"); //define variables string line = convert.ReadLine(); int conversion; int numberIn; float conversionFactor; Console.WriteLine("Enter the conversion in the form (amount,from,to)"); String inputMeasurement = Console.ReadLine(); string[] inputMeasurementArray = inputMeasurement.Split(','); while (line != null) { string[] fileMeasurementArray = line.Split(','); if (fileMeasurementArray[0] == inputMeasurementArray[1]) { if (fileMeasurementArray[1] == inputMeasurementArray[2]) { Console.WriteLine("{0}", fileMeasurementArray[2]); } } line = convert.ReadLine(); //convert to int numberIn = Convert.ToInt32(inputMeasurementArray[0]); conversionFactor = Convert.ToInt32(fileMeasurementArray[2]); conversion = (numberIn * conversionFactor); } Console.ReadKey(); } } } Hello, I am trying to get the calculating going. On the line conversionFactor = Convert.ToInt32(fileMeasurementArray[2]);, I am getting an error saying "Input string was not in correct format". Please help! The text file consists of the following: ounce,gram,28.0 pound,ounce,16.0 pound,kilogram,0.454 pint,litre,0.568 inch,centimetre,2.5 mile,inch,63360.0

    Read the article

  • Strings in .NET are Enumerable

    - by Scott Dorman
    It seems like there is always some confusion concerning strings in .NET. This is both from developers who are new to the Framework and those that have been working with it for quite some time. Strings in the .NET Framework are represented by the System.String class, which encapsulates the data manipulation, sorting, and searching methods you most commonly perform on string data. In the .NET Framework, you can use System.String (which is the actual type name or the language alias (for C#, string). They are equivalent so use whichever naming convention you prefer but be consistent. Common usage (and my preference) is to use the language alias (string) when referring to the data type and String (the actual type name) when accessing the static members of the class. Many mainstream programming languages (like C and C++) treat strings as a null terminated array of characters. The .NET Framework, however, treats strings as an immutable sequence of Unicode characters which cannot be modified after it has been created. Because strings are immutable, all operations which modify the string contents are actually creating new string instances and returning those. They never modify the original string data. There is one important word in the preceding paragraph which many people tend to miss: sequence. In .NET, strings are treated as a sequence…in fact, they are treated as an enumerable sequence. This can be verified if you look at the class declaration for System.String, as seen below: // Summary:// Represents text as a series of Unicode characters.public sealed class String : IEnumerable, IComparable, IComparable<string>, IEquatable<string> The first interface that String implements is IEnumerable, which has the following definition: // Summary:// Exposes the enumerator, which supports a simple iteration over a non-generic// collection.public interface IEnumerable{ // Summary: // Returns an enumerator that iterates through a collection. // // Returns: // An System.Collections.IEnumerator object that can be used to iterate through // the collection. IEnumerator GetEnumerator();} As a side note, System.Array also implements IEnumerable. Why is that important to know? Simply put, it means that any operation you can perform on an array can also be performed on a string. This allows you to write code such as the following: string s = "The quick brown fox";foreach (var c in s){ System.Diagnostics.Debug.WriteLine(c);}for (int i = 0; i < s.Length; i++){ System.Diagnostics.Debug.WriteLine(s[i]);} If you executed those lines of code in a running application, you would see the following output in the Visual Studio Output window: In the case of a string, these enumerable or array operations return a char (System.Char) rather than a string. That might lead you to believe that you can get around the string immutability restriction by simply treating strings as an array and assigning a new character to a specific index location inside the string, like this: string s = "The quick brown fox";s[2] = 'a';   However, if you were to write such code, the compiler will promptly tell you that you can’t do it: This preserves the notion that strings are immutable and cannot be changed once they are created. (Incidentally, there is no built in way to replace a single character like this. It can be done but it would require converting the string to a character array, changing the appropriate indexed location, and then creating a new string.)

    Read the article

  • c# string interning

    - by CodingThunder
    I am trying to understand string interning and why is doesn't seem to work in my example. The point of the example is to show Example 1 uses less (a lot less memory) as it should only have 10 strings in memory. However, in the code below both example use roughly the same amount of memory (virtual size and working set). Please advice why example 1 isn't using a lot less memory? Thanks Example 1: IList<string> list = new List<string>(10000); for (int i = 0; i < 10000; i++) { for (int k = 0; k < 10; k++) { list.Add(string.Intern(k.ToString())); } } Console.WriteLine("intern Done"); Console.ReadLine(); Example 2: IList<string> list = new List<string>(10000); for (int i = 0; i < 10000; i++) { for (int k = 0; k < 10; k++) { list.Add(k.ToString()); } } Console.WriteLine("intern Done"); Console.ReadLine();

    Read the article

  • Having trouble creating vectors of System::String^

    - by Justen
    So I have a regex expression to parse certain parts of a file name. I'm trying to store each part in its own vector until I use it later, but it won't let me. One error I get when I try making a vector of System::String^ is that error C3698: 'System::String ^' : cannot use this type as argument of 'new' Then, when I try just making a vector of std::string, it can't implicitly convert to type System::String^, and casting won't work either. void parseData() { System::String^ pattern = "(\\D+)(\\d+)(\\w{1})(\\d+)\\.(\\D{3})"; std::vector < System::String^ > x, y, filename, separator; Regex re( pattern ); for ( int i = 0; i < openFileDialog1->FileNames->Length; i++ ) { Match^ m = re.Match( openFileDialog1->FileNames[i] ); filename.push_back( m->Groups[0]->Value );/* x.push_back( m->Groups[1]->Value ); separator.push_back( m->Groups[2]->Value ); y.push_back( m->Groups[3]->Value );*/ } }

    Read the article

  • boost::python string-convertible properties

    - by Checkers
    I have a C++ class, which has the following methods: class Bar { ... const Foo& getFoo() const; void setFoo(const Foo&); }; where class Foo is convertible to std::string (it has an implicit constructor from std::string and an std::string cast operator). I define a Boost.Python wrapper class, which, among other things, defines a property based on previous two functions: class_<Bar>("Bar") ... .add_property( "foo", make_function( &Bar::getFoo, return_value_policy<return_by_value>()), &Bar::setFoo) ... I also mark the class as convertible to/from std::string. implicitly_convertible<std::string, Foo>(); implicitly_convertible<Foo, std::string>(); But at runtime I still get a conversion error trying to access this property: TypeError: No to_python (by-value) converter found for C++ type: Foo How to achieve the conversion without too much boilerplate of wrapper functions? (I already have all the conversion functions in class Foo, so duplication is undesirable.

    Read the article

  • Tool to detect use/abuse of String.Concat (where StringBuilder should be used)

    - by Mark Rushakoff
    It's common knowledge that you shouldn't use a StringBuilder in place of a small number of concatenations: string s = "Hello"; if (greetingWorld) { s += " World"; } s += "!"; However, in loops of a significant size, StringBuilder is the obvious choice: string s = ""; foreach (var i in Enumerable.Range(1,5000)) { s += i.ToString(); } Console.WriteLine(s); Is there a tool that I can run on either raw C# source or a compiled assembly to identify where in the source code that String.Concat is being called? (If you're not familiar, s += "foo" is mapped to String.Concat in the IL output.) Obviously, I can't realistically search through an entire project and evaluate every += to identify whether the lvalue is a string. Ideally, it would only point out calls inside a for/foreach loop, but I would even put up with all the false positives of noting every String.Concat. Also, I'm aware that there are some refactoring tools that will automatically refactor my code to use StringBuilder, but I am only interested in identifying the Concat usage at this point. I routinely run Gendarme and FxCop on my code, and neither of those tools identify what I've described.

    Read the article

  • Serializable object in intent returning as String

    - by B_
    In my application, I am trying to pass a serializable object through an intent to another activity. The intent is not entirely created by me, it is created and passed through a search suggestion. In the content provider for the search suggestion, the object is created and placed in the SUGGEST_COLUMN_INTENT_EXTRA_DATA column of the MatrixCursor. However, when in the receiving activity I call getIntent().getSerializableExtra(SearchManager.EXTRA_DATA_KEY), the returned object is of type String and I cannot cast it into the original object class. I tried making a parcelable wrapper for my object that calls out.writeSerializable(...) and use that instead but the same thing happened. The string that is returned is like a generic Object toString(), i.e. com.foo.yak.MyAwesomeClass@4350058, so I'm assuming that toString() is being called somewhere where I have no control. Hopefully I'm just missing something simple. Thanks for the help! Edit: Some of my code This is in the content provider that acts as the search authority: //These are the search suggestion columns private static final String[] COLUMNS = { "_id", // mandatory column SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA }; //This places the serializable or parcelable object (and other info) into the search suggestion private Cursor getSuggestions(String query, String[] projection) { List<Widget> widgets = WidgetLoader.getMatches(query); MatrixCursor cursor = new MatrixCursor(COLUMNS); for (Widget w : widgets) { cursor.addRow(new Object[] { w.id w.name w.data //This is the MyAwesomeClass object I'm trying to pass }); } return cursor; } This is in the activity that receives the search suggestion: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Object extra = getIntent().getSerializableExtra(SearchManager.EXTRA_DATA_KEY); //extra.getClass() returns String, when it should return MyAwesomeClass, so this next line throws a ClassCastException and causes a crash MyAwesomeClass mac = (MyAwesomeClass)extra; ... }

    Read the article

  • <string xmlns=''> was not expected in c#

    - by Nishant
    Hi all I am trying to serialize value in xml. Every time I am getting <string xmlns=''> was not expected in c# Not able to find root cause plz help me out here. namespace CustomDataType.usercontrols { public partial class CustomDataTypes : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor { private Status _umbval; public object value { get { var status = GetStatus(); return SerializationHelper.ValueToXmlString(status); } set { //if (value == null || string.IsNullOrEmpty(value.ToString())) //{ // _umbval = Status.Empty; //} //else //{ _umbval =(Status)SerializationHelper.ValueFromXmlString(value,typeof(Status)); //} } } } } using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xml.Serialization; namespace CustomDataType { [Serializable] [XmlRoot("StatuMain")] public class Status { [XmlElement("statusvalue")] public string StatusValue { get; set; } [XmlElement("statusvalue1")] public string StatusValue1 { get; set; } [XmlElement("statusvalue2")] public string StatusValue2 { get; set; } [XmlElement("statusvalue3")] public string StatusValue3 { get; set; } //[XmlElement("isEmailChecked")] //public bool HasEmailChecked { get; set; } //[XmlElement("datetime")] //public DateTime Date { get; set; } public static Status Empty { get { var schedule = new Status(); schedule = null; return schedule; } } } }

    Read the article

  • Convert enumeration to string

    - by emptyheaded
    I am trying to build a function that converts an item from an enum to its corresponding string. The enums I use are fairly long, so I didn't want to use a switch-case. I found a method using boost::unordered_map very convenient, but I don't know how to make a default return (when there is no item matching the enum). const boost::unordered_map<enum_type, const std::string> enumToString = boost::assign::map_list_of (data_1, "data_1") (data_2, "data_2"); I tried to create an additional function: std::string convert(enum_type entry) { if (enumToString.find(entry)) // not sure what test to place here, return enumToString.at(entry); //because the find method returns an iter else return "invalid_value"; } I even tried something exceedingly wrong: std::string convert(enum_type entry) { try{ return enumToString.at(entry); } catch(...){ return "invalid_value"; } } Result: evil "Debug" runtime error. Can somebody give me a suggestion on how to either 1) find an easier method to convert enum to a string with the same name as the enum item 2) find a way to use already built boost methods to get a default value from a hash map (best option) 3) find what to place in the test to use a function that returns either the pair of the key-value, or a different string if the key is not found in the map. Thank you very much.

    Read the article

  • Pick up relevant information from a string using regular expression C#3.0

    - by Newbie
    Hi, I have a situation. I have been given some file name which can be like <filename>YYYYMMDD<fileextension> some valid file names that will satisfy the above pattern are as under xxx20100326.xls, xxx2v20100326.csv, x_20100326.xls, xy2z_abc_20100326_xyz.csv, abc.xyz.20100326.doc, ab2.v.20100326.doc, abc.v.20100326_xyz.xls In what ever be the above defined case, I need to pick up the dates only. So for all the cases, the output will be 20100326. I am trying to achieve the same but no luck. Here is what I have done so far string testdata = "x2v20100326.csv"; string strYYYY = @"\d{4}"; string strMM = @"(1[0-2]|0[1-9])"; string strDD = @"(3[0-1]|[1-2][0-9]|0[1-9])"; string regExPattern = @"\A" + strYYYY + strMM + strDD + @"\Z"; Regex regex = new Regex(regExPattern); Match match = regex.Match(testdata); if (match.Success) { string result = match.Groups[0].Value; } I am using c#3.0 and dotnet framework 3.5 Please help. It is very urgent Thanks in advance.

    Read the article

  • PasswordFiled char[] to String in Java connection MySql?

    - by user1819551
    This is a jFrame to connect to the database and this is in the button connect. My issue is in the passwordField NetBeans make me do a char[], but my .getConnection not let me insert the char[] ERROR: "no suitable method found for getConnection(String,String,char[])". So I will change to String right? So when I change and run the jFrame said access denied. when I start doing the System.out.println(l) " Give me the right answer" Like this: "Alex". But when I do the System.out.println(password) "Give me the Array spaces and not the value" Like this: jdbc:mysql://localhost/home inventory root [C@5be5ab68 <--- Array space . What I doing wrong? try { Class.forName("org.gjt.mm.mysql.Driver"); //Load the driver String host = "jdbc:mysql://"+tServerHost.getText()+"/"+tSchema.getText(); String uName = tUsername.getText(); char[] l = pPassword.getPassword(); System.out.println(l); String password= l.toString(); System.out.println(host+uName+l); con = DriverManager.getConnection(host, uName, password); System.out.println(host+uName+password); } catch (SQLException | ClassNotFoundException ex) { JOptionPane.showMessageDialog(this, ex.getMessage()); } }

    Read the article

  • c# logic to get the first non-repeating(distinct) character from the string

    - by NoviceToDotNet
    In c# i want to create logic that if i a string like abcabda is passed to a method then it should return first non repeative character from string like in above it should return c. i am unable to convert a string to array of character then how to make comparison of each array character to the string and return the first non repeative character. CanI make it like this? class A { static void main() { A a=new A(); char ch=a.m1(abcabd); } } class B { char m1(string s) { string s1=s; char[] ch1=new char[s.length]; for(int x=0; x<s.length;x++) { ch1[x]=s[x]; } for(int x=0; x<s.length; x++) { for(int y=0; y<s.lenth; y++) { if(s[x]=ch1[y]) { /// here i am confused how to create logic for comparison please let me know // and how to return the character } } } } }

    Read the article

  • Postfix/ClamAV not stopping viruses under Virtualmin

    - by Josh
    I am using Virtualmin and have it set up to have Postfix scan incoming emails with ClamAV (using clamdscan) and delete any emails which contain a virus. However when I email myself the EICAR test string, it comes through just fine. I know ClamAV will report this file as a virus. How can I troubleshoot this / what could be wrong?

    Read the article

  • Using JAXB to unmarshal/marshal a List<String> - Inheritance

    - by gerry
    I've build the following case. An interface for all JAXBLists: public interface JaxbList<T> { public abstract List<T> getList(); } And an base implementation: @XmlRootElement(name="list") public class JaxbBaseList<T> implements JaxbList<T>{ protected List<T> list; public JaxbBaseList(){} public JaxbBaseList(List<T> list){ this.list=list; } @XmlElement(name="item" ) public List<T> getList(){ return list; } } As well as an implementation for a list of URIs: @XmlRootElement(name="uris") public class JaxbUriList2 extends JaxbBaseList<String> { public JaxbUriList2() { super(); } public JaxbUriList2(List<String> list){ super(list); } @Override @XmlElement(name="uri") public List<String> getList() { return list; } } And I'm using the List in the following way: public JaxbList<String> init(@QueryParam("amount") int amount){ List<String> entityList = new Vector<String>(); ... enityList.add("http://uri"); ... return new JaxbUriList2(entityList); } I thought the output should be: <uris> <uri> http://uri </uri> ... </uris> But it is something like this: <uris> <item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string"> http://uri </item> ... <uri> http://uri </uri> ... </uris> I think it has something to do with the inheritance, but I don't get it... What's the problem? - How can I fix it? Thanks in advance!

    Read the article

  • How to dynamically expand a string in C

    - by sa125
    Hi - I have a function that recursively makes some calculations on a set of numbers. I want to also pretty-print the calculation in each recursion call by passing the string from the previous calculation and concatenating it with the current operation. A sample output might look like this: 3 (3) + 2 ((3) + 2) / 4 (((3) + 2) / 4) x 5 ((((3) + 2) / 4) x 5) + 14 ... and so on So basically, the second call gets 3 and appends + 2 to it, the third call gets passed (3) + 2 , etc. My recursive function prototype looks like this: void calc_rec(int input[], int length, char * previous_string); I wrote a 2 helper functions to help me with the operation, but they implode when I test them: /********************************************************************** * dynamically allocate and append new string to old string and return a pointer to it **********************************************************************/ char * strapp(char * old, char * new) { // find the size of the string to allocate int len = sizeof(char) * (strlen(old) + strlen(new)); // allocate a pointer to the new string char * out = (char*)malloc(len); // concat both strings and return sprintf(out, "%s%s", old, new); return out; } /********************************************************************** * returns a pretty math representation of the calculation op **********************************************************************/ char * mathop(char * old, char operand, int num) { char * output, *newout; char fstr[50]; // random guess.. couldn't think of a better way. sprintf(fstr, " %c %d", operand, num); output = strapp(old, fstr); newout = (char*)malloc( 2*sizeof(char)+sizeof(output) ); sprintf(newout, "(%s)", output); free(output); return newout; } void test_mathop() { int i, total = 10; char * first = "3"; printf("in test_mathop\n"); while (i < total) { first = mathop(first, "+", i); printf("%s\n", first); ++i; } } strapp() returns a pointer to newly appended strings (works), and mathop() is supposed to take the old calculation string ("(3)+2"), a char operand ('+', '-', etc) and an int, and return a pointer to the new string, for example "((3)+2)/3". Any idea where I'm messing things up? thanks.

    Read the article

  • SharedObject (Flex 3.2) behaving unexpectedly when query string present in URL

    - by rhtx
    Summary: The behavior detailed below seems to indicate that if your app at www.someplace.com sets/retrieves data via a SharedObject, there is some sort of .sol collision if the user hits your app at someplace.com, and then later at someplace.com?name=value. Can anyone confirm or refute this? I'm working on a Flex web app that presents the user with a login page. When the user has logged in, he/she is presented with a 'room' which is associated with a 'group'. We store the last-visited room/group combination in a SharedObject - so when a given user logs in, they are taken into the most recent room in which they were active. That works fine, but we also have an auto-login system which involves the user clicking on a link to the app url with a query string attached. There are two types of these links. 1) the query string includes username, groupId, and roomId 2) the query string includes only the username Because we are working fast and have only a few developers, the auto-login system is built on the last-vist system. During the auto-login process, the url is inspected and if groupId and roomId values are found in the query string, the SharedObject is opened and the last-visit group/room id values are overwritten by the param values. That works fine, also, when the app is hit with a query string of the second type (no groupId and roomId params), the app goes to the SharedObject to get the stored room and group id values, as it normally would. And here's the problem: The values it comes back with are whatever the last room/group param values were, not whatever the last last-visit room/group values are. And if the given user has never hit the app with query string that included group and room id values, the app gets null values from the SharedObject. It took some digging around, but what it looks like is happening is that a second set of data is being stored/expected in the SharedObject if a query string is present in the URL. Looking at the .sol file in a text editor I see more untranslated code, and additional group and room values, once I've hit the app with URLs that contain query strings. I'm not finding anything on the web about this, but that may just be due to a lack of necessary search skills. Has anyone else run into anything similar? Or do you know how to address this? I've tried setting Security.exactSettings to false, already - was really hoping that was going to work.

    Read the article

  • Is there a standard way to encode a .NET string into javascript string for use in MS AJAX?

    - by Rich Andrews
    I'm trying to pass the output of a SQL Server exception to the client using the RegisterStartUpScript method of the MS ScriptManager. This works fine for some errors but when the exception contains single quotes the alert fails. I dont want to only escape single quotes though - Is there a standard function i can call to escape any special chars for use in Javascript? string scriptstring = "alert('" + ex.Message + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", scriptstring , true); Thanks tpeczek, the code almost worked for me :) but with a slight amendment (the escaping of single quotes) it works a treat. I've included my amended version here... public class JSEncode { /// <summary> /// Encodes a string to be represented as a string literal. The format /// is essentially a JSON string. /// /// The string returned includes outer quotes /// Example Output: "Hello \"Rick\"!\r\nRock on" /// </summary> /// <param name="s"></param> /// <returns></returns> public static string EncodeJsString(string s) { StringBuilder sb = new StringBuilder(); sb.Append("\""); foreach (char c in s) { switch (c) { case '\'': sb.Append("\\\'"); break; case '\"': sb.Append("\\\""); break; case '\\': sb.Append("\\\\"); break; case '\b': sb.Append("\\b"); break; case '\f': sb.Append("\\f"); break; case '\n': sb.Append("\\n"); break; case '\r': sb.Append("\\r"); break; case '\t': sb.Append("\\t"); break; default: int i = (int)c; if (i < 32 || i > 127) { sb.AppendFormat("\\u{0:X04}", i); } else { sb.Append(c); } break; } } sb.Append("\""); return sb.ToString(); } } As mentioned below - original source: here

    Read the article

  • Use WLST to Delete All JMS Messages From a Destination

    - by james.bayer
    I got a question today about whether WebLogic Server has any tools to delete all messages from a JMS Queue.  It just so happens that the WLS Console has this capability already.  It’s available on the screen after the “Show Messages” button is clicked on a destination’s Monitoring tab as seen in the screen shot below. The console is great for something ad-hoc, but what if I want to automate this?  Well it just so happens that the console is just a weblogic application layered on top of the JMX Management interface.  If you look at the MBean Reference, you’ll find a JMSDestinationRuntimeMBean that includes the operation deleteMessages that takes a JMS Message Selector as an argument.  If you pass an empty string, that is essentially a wild card that matches all messages. Coding a stand-alone JMX client for this is kind of lame, so let’s do something more suitable to scripting.  In addition to the console, WebLogic Scripting Tool (WLST) based on Jython is another way to browse and invoke MBeans, so an equivalent interactive shell session to delete messages from a destination would looks like this: D:\Oracle\fmw11gr1ps3\user_projects\domains\hotspot_domain\bin>setDomainEnv.cmd D:\Oracle\fmw11gr1ps3\user_projects\domains\hotspot_domain>java weblogic.WLST   Initializing WebLogic Scripting Tool (WLST) ...   Welcome to WebLogic Server Administration Scripting Shell   Type help() for help on available commands   wls:/offline> connect('weblogic','welcome1','t3://localhost:7001') Connecting to t3://localhost:7001 with userid weblogic ... Successfully connected to Admin Server 'AdminServer' that belongs to domain 'hotspot_domain'.   Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port or Admin port should be used instead.   wls:/hotspot_domain/serverConfig> serverRuntime() Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root. For more help, use help(serverRuntime)   wls:/hotspot_domain/serverRuntime> cd('JMSRuntime/AdminServer.jms/JMSServers/JMSServer-0/Destinations/SystemModule-0!Queue-0') wls:/hotspot_domain/serverRuntime/JMSRuntime/AdminServer.jms/JMSServers/JMSServer-0/Destinations/SystemModule-0!Queue-0> ls() dr-- DurableSubscribers   -r-- BytesCurrentCount 0 -r-- BytesHighCount 174620 -r-- BytesPendingCount 0 -r-- BytesReceivedCount 253548 -r-- BytesThresholdTime 0 -r-- ConsumersCurrentCount 0 -r-- ConsumersHighCount 0 -r-- ConsumersTotalCount 0 -r-- ConsumptionPaused false -r-- ConsumptionPausedState Consumption-Enabled -r-- DestinationInfo javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=DestinationInfo,items=((itemName=ApplicationName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=ModuleName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName openmbean.SimpleType(name=java.lang.Boolean)),(itemName=SerializedDestination,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=ServerName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=Topic,itemType=javax.management.openmbean.SimpleType(name=java.lang.Boolean)),(itemName=VersionNumber,itemType=javax.management.op ule-0!Queue-0, Queue=true, SerializedDestination=rO0ABXNyACN3ZWJsb2dpYy5qbXMuY29tbW9uLkRlc3RpbmF0aW9uSW1wbFSmyJ1qZfv8DAAAeHB3kLZBABZTeXN0ZW1Nb2R1bGUtMCFRdWV1ZS0wAAtKTVNTZXJ2ZXItMAAOU3lzdGVtTW9kdWxlLTABAANBbGwCAlb6IS6T5qL/AAAACgEAC0FkbWluU2VydmVyAC2EGgJW+iEuk+ai/wAAAAsBAAtBZG1pblNlcnZlcgAthBoAAQAQX1dMU19BZG1pblNlcnZlcng=, ServerName=JMSServer-0, Topic=false, VersionNumber=1}) -r-- DestinationType Queue -r-- DurableSubscribers null -r-- InsertionPaused false -r-- InsertionPausedState Insertion-Enabled -r-- MessagesCurrentCount 0 -r-- MessagesDeletedCurrentCount 3 -r-- MessagesHighCount 2 -r-- MessagesMovedCurrentCount 0 -r-- MessagesPendingCount 0 -r-- MessagesReceivedCount 3 -r-- MessagesThresholdTime 0 -r-- Name SystemModule-0!Queue-0 -r-- Paused false -r-- ProductionPaused false -r-- ProductionPausedState Production-Enabled -r-- State advertised_in_cluster_jndi -r-- Type JMSDestinationRuntime   -r-x closeCursor Void : String(cursorHandle) -r-x deleteMessages Integer : String(selector) -r-x getCursorEndPosition Long : String(cursorHandle) -r-x getCursorSize Long : String(cursorHandle) -r-x getCursorStartPosition Long : String(cursorHandle) -r-x getItems javax.management.openmbean.CompositeData[] : String(cursorHandle),Long(start),Integer(count) -r-x getMessage javax.management.openmbean.CompositeData : String(cursorHandle),Long(messageHandle) -r-x getMessage javax.management.openmbean.CompositeData : String(cursorHandle),String(messageID) -r-x getMessage javax.management.openmbean.CompositeData : String(messageID) -r-x getMessages String : String(selector),Integer(timeout) -r-x getMessages String : String(selector),Integer(timeout),Integer(state) -r-x getNext javax.management.openmbean.CompositeData[] : String(cursorHandle),Integer(count) -r-x getPrevious javax.management.openmbean.CompositeData[] : String(cursorHandle),Integer(count) -r-x importMessages Void : javax.management.openmbean.CompositeData[],Boolean(replaceOnly) -r-x moveMessages Integer : String(java.lang.String),javax.management.openmbean.CompositeData,Integer(java.lang.Integer) -r-x moveMessages Integer : String(selector),javax.management.openmbean.CompositeData -r-x pause Void : -r-x pauseConsumption Void : -r-x pauseInsertion Void : -r-x pauseProduction Void : -r-x preDeregister Void : -r-x resume Void : -r-x resumeConsumption Void : -r-x resumeInsertion Void : -r-x resumeProduction Void : -r-x sort Long : String(cursorHandle),Long(start),String[](fields),Boolean[](ascending)   wls:/hotspot_domain/serverRuntime/JMSRuntime/AdminServer.jms/JMSServers/JMSServer-0/Destinations/SystemModule-0!Queue-0> cmo.deleteMessages('') 2 where the domain name is “hotspot_domain”, the JMS Server name is “JMSServer-0”, the Queue name is “Queue-0” and the System Module is named “SystemModule-0”.  To invoke the operation, I use the “cmo” object, which is the “Current Management Object” that represents the currently navigated to MBean.  The 2 indicates that two messages were deleted.  Combining this WLST code with a recent post by my colleague Steve that shows you how to use an encrypted file to store the authentication credentials, you could easily turn this into a secure automated script.  If you need help with that step, a long while back I blogged about some WLST basics.  Happy scripting.

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >