Thursday, 15 April 2010

xml serialization - Can we create a java object from an xml without knowing what object it is belong to -


I have an XML content, for which I do not know which class it belongs to Need to create a dynamic Java object? Is it possible to do this? It can be a simple Java object, so we can use the Java Reflection to get value from that object. For example,

  & lt; Employee & gt; & Lt; Name & gt; Jack & lt; / Name & gt; & Lt; Designation & gt; Manager & lt; / Designation & gt; & Lt; Department & gt; Finance & lt; / Department & gt; & Lt; / Staff & gt;   

So, with this XML, I need to convert to an employee object. But, I did not have an employee class in my class path, is it possible to create an object with XML?

  file fxmlFile = new file "Employee.xml"); Documentbilder factory dbfc = documentbilderfactor.Newinstance (); DocumentBuilder debugger = DBFTC NE DocumentBuilder (); Document doctor = debugger Parse (fxma file); // Optional, but recommended // read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work.doc.getDocumentElement (). Normal ( ); System.out.println ("Root Element:" + doc.getDocumentElement (.) GetNodeName ()); Node list nList = doc.getElementsByTagName ("employee"); Println ("----------------------------"); (At Temp = 0; Temp & LT; NLIIT: ATLANMENT (); Temporary ++) {Node NND = NLIT. ITM (temporary); System.out.println ("\ n Current element:" + nNode.getNodeName ()); If (nNode.getNodeType () == node. ELEMENT_NODE) ​​{Element EElment = (Element) nNode; System.out.println ("name: -" + eElement.getElementsByTagName ("name"). Item (0) .getTextContent ()); System.out.println ("Designation: -" + eElement.getElementsByTagName ("Designation"). Item (0) .getTextContent ()); System.out.println ("Department: -" + eElement.getElementsByTagName ("Department"). Item (0) .getTextContent ()); }}    

Proper explanation of JavaScript execution order -


I know there are so many questions on this topic, but they are all in accordance with a specific case. I am asking this question and hoping for an answer that everyone can use it while thinking about this matter.

Say that I have three functions that need to be executed in order, and they all do Async

For two tasks it is easy with callback: / P>

  var fOne = function (callback) {// do stuff callback (); }; Var fTwo = function () {// do stuff};   

Calling:

  fOne (fTwo);   

The FOO makes it to run after completion, how does the FTH in this case connect, so that it can be run after FTO, which is run after FOn?

Actually, if I think your question is correct, then you can add a logic to the FTO If you want to pass Lambda, then FTO has to take a callback and call it.

  var fOne = function (callback) {// do stuff callback (); }; Var fTwo = function (callback) {// do stuff callback (); }; Var fThree = function () {// do stuff}; Fun (function () {FTO (FT-2);}); // & lt; - Lambda    

visual studio 2012 - Why does select source for a SQL Schema Comparison cause VS2012 to crash? -


For instance, SQL & gt; Compare schema & gt; Visual Studio 2012 causes crash due to new schema comparison and then "attempting to select the source". Apart from trying to re-establish any possible solution there (hopefully for months it has been worked out)

Note: ? View an example of studio accident trying to debug shows an exception

  application: Devenvkexe Framework Version: v4.0.30319 Description: The process of a non-action Was ended due to the exception. Exception information: System.Security.Cryptography.CryptographicException ads: Microsoft.VisualStudio.Data.DataProtection.DecryptString (System.String) (System on Microsoft.VisualStudio.Data.Tools.Design.Core.Common.SqlClient.SqlUtils.DecryptConnectionString. Microsoft.VisualStudio.Data.Tools.Package.UI.DatabaseConnectionControl + Knekshnitm string) on ​​Microsoft.VisualStudio.Data.Tools.Design.Core.Common.SqlClient.ServerExplorerConnection.get_DisplayNameWithDatabase (). Start Microsoft.VisualStudio.Data.Tools.Package.UI.DatabaseConnectionControl.DatabaseConnectionControl_Load on (Microsoft.VisualStudio.Data.Tools Microsoft.VisualStudio.Data.Tools.Package.UI.DatabaseConnectionControl.PopulateDatabaseCombo () (System. Object, System. EventArgs)    

"itemprop =" text ">

After trying to follow the information, I see was checked which was accessible registry entries. HKCU \ Software \ Microsoft \ VisualStudio \ 11.0 \ SSDT \ ConnectionMruList is found under remove everything.

stringtemplate 4 - Is it possible to combine group files and group directories? -


I am using StringTemplate to create HTML and I use STGroupFile and STGroupDir This way I have a directory of group files. In this way I can include multiple templates in a file, but I can add templates from many files. It does not appear that there is support for it, but I thought that if I see something then I will see it.

If you are wondering why I would like to do this, see an example from the StringTemplate Docs:

  test (name) :: = "$ name: bracket () $ "// Apply bracket template in each name bracket (x): =" [$ x $] "// parameter parameter with square bracket   

All the above one file (Test.st) and we are using STGroupDir , it will be unable to resolve the "bracket (x)" template unless it is a separate file (bracket.st) Not in In this particular example, the bracket is like a local assistant that is useful for cleaning the main template. In this case, you probably do not want to show the bracket outside of the test.

However, if you want to create a library of simple supportive templates, you can find them all in one file and each of them is accessible to templates in other files.

"post-text" itemprop = "text">

Disclaimer: I am using StringTemplate in C # Em>

You have to use .stg files with a group of templates. StringTemplate groups can import groups of other templates or templates, and you can create those groups from a file or directory.

How to check if a folder exists in google drive? (ruby client) -


It seems that I can only return the contents of a folder, but there is no information about the folder.

  Result = client.execute ({: api_method => drive.files.list,: q = & gt; "mimeType = 'app / vnd.google-apps.folder' and Trashed = false and title = '# {App_folder_name}' ",: maxResults => 1})   

returned results. To_hash ["Item"] is populated with the contents of the array folder (sub folders and files). How do I get information about folders only? What I want to do, checks whether it exists or not. And it seems that more than one entry is being neglected in the array.

A folder Google Drive is like a regular file but a special MIME type ("app / vnd. Google-apps.folder "). After you have the ID of the folder, you can access the metadata with a request:

  ## # Print the file's metadata # # the ultimate [Google :: epicilient] Client #Official Client Instance # @ PRAM [String] File_ID # To print the #RetinNil DRP print_file (client, file_id) drive = client. Diskped_pi ('drive', 'V2') result = client.execute (: api_method = & gt; @ drive.files.get ,: parameter = & gt; {'fileId' = & gt; file_id}) if result.status == 200 file = result.data "title: # {file.title}" puts "Description: # {file.description}" puts "MIME type: # {file.mime_type}" and adds "An error occurred: # {Result.data ['error'] ['message']} "end and end    

sql - Read in only certain column names from TSV file into R -


I have a large TSV file that I can not read in R due to its size.

I only want to read the header name in the selected column, e.g. "Health".

How can I go about doing this?

See a read.table code colClasses : df & lt; - read.table (header = TRUE, colClasses = c (NA, "NULL", NA), text = 'ABC 1 2 3 4 5 6') DF # AC # 1 1 3 # 2 4 6 < / Pre>

Update:

To select names, first read in the header and then create a vector for the callclass:

  Read the # header header; & Lt; - read.table (header = FALSE, nrow = 1, text = 'ABC 1 2 3 4 5 6') # We want to take the call & lt; - c ('A', 'B') # Create a vector for callclose lecols & lt; - ifelse (t (header) %%, na, 'toll') # selected column df & lt; - read.table (header = TRUE, colClasses = lecoles, text = 'ABC 1 2 3 4 5 6')    

button - Fitting signals to slots in Qt -


I enable a QPushButton after another QPushButton Trying to click and I have participated in a problem first QPushButton one clicked () can remove the signal, while the second QPushButton has only the setEnabled (bool) slots and set to disable (boole) .

Actually, I am trying to do

  connect (ui-> pbViewVolume, signal (clicked)), UI-> pbSaveAsImage , Slot (setEnabled)));   

Since it is not possible to send a signal with less parameters compared to the slot, how can I do this? My only way is my main window like

  zero EnableSaveAsImageButton () {ui- & gt; PbSaveAsImage-> To create a public slot for setEnabled (true); }   

But I will not fill my main window with functions of this type of garbage.

  • You do not need to make this slot public, make it private. "Post-lesson" itemprop = "text">
    1. You have to create that slot.
    2. This function is not garbage.