Is it possible to list the used imports from a JAR File like you can with a DLL in .NET?
I found programs that can list the content of the JAR file, like:
http://jarbrowser.sourceforge.net/
but I'd like to list the imports.
You could try Jdepend.
After compilation the import statements are no longer available,
only the types of the objects, you would need to analyze the byte code to do that.
For more details see class file format or even more java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf
Related
How does QT Linguist know the ts file defined in the project file is for a specific language? (Is the "_ja" characters in the name how it determines the language? I couldn't find anything in the documentation.)
I have a ts file defined as "testdata_ja.ts" in the project file. Running lupdate, the file is generated. In the ts file there is a line:
<TS version="2.1" language="ja_JP">
lupdate seemed to figure it out, but nothing was translated, all entries are "unfinished". I put an entry in the code that was in the Japanese phrase book.
The phrasebook is just a hint/help for the human translator, lupdate will never automatically translate anything for you. Any translations in the .ts file still need to be populated and/or marked as completed "manually" (typically in QtLinguist, but one could use any text editor, or a script, or whatever).
What would be the best practice - if there is any - to parse multiple config files?
I want to parse the mysql server configuration and also write the configuration again.
The configuration allows to issue multiple lines like:
!includedir /etc/mysql.d/
So the interesting thing is, that some configuration may be located in the main file but other may be located in a sub file.
I think pyparsing only works on ONE single file or one content string.
So I probably first need to read all files and maybe restructures the contents like adding headers for the different files...
====main file====
[mysql]
....
!includedir /etc/mysql.d/
====/etc/mysql.d/my.cnf====
[client]
.....
I would only have one pyparsing call.
Then I could parse everything into one big data object, group the file sections and have the file names as keys. This way I could also write the data back to the disk...
The other possibility would be to parse the main file and programmatically parse all other files that were found in the main file.
Thus I would have several pyparsing calls.
What do you think?
In your pyparsing code, attach a parse action to the expression that matches the include statements, have it parse the contents of the referenced files or directory of files, then merge those results into the current parse output. The parse action would make the successive calls to parseString, your code would only make a single call.
See this new example added to the pyparsing examples directory: https://github.com/pyparsing/pyparsing/blob/master/examples/include_preprocessor.py
Is there any object/class in CRM 2011 SDK to which I can feed the customizations zip file and then I can simply use its properties/methods to read/validate the contents of the customizations zip file before importing?
The only relevant object I was able to find was ImportSolutionRequest. But it only takes the customizations zip file as a byte[] using the CustomizationFile property exposed on it. But it doesnt let me read the contents of the file. Too bad :(
Also, if there is any other way to achieve the same I am open for it.
Based on looking at the contents of a customizations.zip file, it should be possible to use the System.IO.Packaging namespace to unpack the zip and then read the inner customizations.xml into an XML document.
At the moment i get file extension of the file like :
string fileExt = System.IO.Path.GetExtension(filUpload.FileName);
But if the user change the file extension of the file ( for example user could rename "test.txt" to "test.jpg" ), I can't get the real extension . What's the solution ?
You seem to be asking if you can identify file-type from its content.
Most solutions will indeed attempt the file extension, but there are too many different possible file types to be reliably identifiable.
Most approaches use the first several bytes of the file to determine what they are.
Here is one list, here another.
If you are only worried about text vs binary, see this SO question and answers.
See this SO answer for checking if a file is a JPG - this approach can be extended to use other file headers as in the first two links in this answer.
Whatever the user renames the file extension to, that is the real file extension.
You should never depend on the file extension to tell you what's in the file, since it can be renamed.
See "how can we check file types before uploading them in asp.net?"
There's no way to get the 'real' file extension - the file extension that you get from the filename is the real one. If file content is your concern, you can retrieve the content type using the .ContentType property and verify that it is a content type that you are expecting - eg. image/jpg.
I mean without input XML file.
I'm using Saxon-EE 9.2.
if you mean to validate the Xquery source file then, the only route I know of is to first convert it to XqueryX using xq2xqx.xsl and then use a xsd schema based on that
An XQuery source file isn't an XML document, so can't be validated with an XML schema. If you really need to, you can use the xq2xqx library to convert XQuery source files into XQueryX documents:
http://monet.nag.co.uk/xq2xml/
The code there needs some tidying up, the XQuery parser linked at
http://www.w3.org/2005/qt-applets/xgrammar.zip
and the Saxon jar - the free one here should work:
http://saxon.sourceforge.net/#F9.4HE
You should end up with a command line something like:
java -cp "saxon9.jar;xquery.jar;trans2.jar" net.sf.saxon.Transform -it:main -o:"xq2xqx.log" -xsl:"xq2xqx.xsl" dump="no$2" xq=test.xquery
which will generate test.xqueryx, and you can then validate the document against the official w3.org schema:
http://www.w3.org/2005/XQueryX/xqueryx.xsd