Perfomance of XSLT-includes vs XSLT-extesions with Java - java

I have a big XML file that lacks information, most of these data are codes and I need to generate a PDF file with the descriptions.
On the other hand, I have all descriptions needed accesible from my java application, the question is: What of the following options is most fast?
Using XSTL-extension for access to the information storaged in a Map
Using XSTL-extension for access to the information storaged in a local database
Using XSTL-include for read a file generated by my java process that contains variables with name=ids and Select=descriptions.
I'm worried about the performance because I'm talking about a lot of ids (data).

I had the same problem few time ago and I decided to use your third option:
Using XSTL-include for read a file generated by my java process that contains variables with name=ids and Select=descriptions.
because in this way yo can be indepedent of you core, not like with extensions.

Related

Best way to get values from a external file in java

I have a java code which I'm currently running as a jar. This code checks for a specific file in the given directory which is currently hard coded in the code.
To give more flexibility and not to touch the code. I would like to have the folers list managed by a different file and the code reads this config file and gets the list of folders each time and execute it.
I would like to know which is the best possible option of maintaining the folder list outside the code so that anyone can update it. Can a properties be used for this ? can we dynamically take values from a property file
In Java you have the java.util.Properties that allow you to load flat key/value data from external resources.
If you need something that can be dynamically updated, there's also the more sophisticated Preferences library. This one allows you to:
Keep data organized in tree structures (it's a tree of nodes, each node storing its own key/value preferences).
Make use of basic types (primitive types, strings and binary data).
Make use of platform-dependent "native" stores transparently (under the hood, it's going to use the file system on Unix systems and registries on Windows by default).
Plug in your own backing store if needed.
Get any data changes performed within the application persisted transparently.
Register node/preference change listeners and react to any change if needed.
The API is quite old and hasn't been updated, but it doesn't mean it's deprecated. It is used mostly with GUI applications (notably, IntelliJ IDEA was storing its configuration using Preferences the last time I checked).
There's also an attempt to revive this library that I made with a project called cross-preferences by integrating modern distributed config stores (such as zookeeper, etcd or consul) as backing stores for java.util.prefs.Preferences and providing a web console for preference management.

Saving Data from a JavaFX-Application without Database

Unfortunately I couldn't find anything specific to this topic / to my problem. Here we go:
I'm building a JavaFX Business Application for a friend of mine. Unfortunately I do not have any possibility to connect to a Database. I want the Application to load a savestate from a file. The application contains a list with clients and the clients got some specific properties. I do not want to hardcode this to a .prop or .txt file, because I'm sure that there's a different way of doing this, isn't there?
Thanks in advance, appreciate it!
Lots of choices for persisting data to local storage. The exact choice depends on your needs. You do not describe enough details to make a specific recommendation.
Here is a list of possibilities, roughly in increasing order of complexity of your data.
Text file
If you have small amounts of simple data, save to a text file. You can store each piece in a separate file, or combine into a single file. Recent versions of Java have new classes to make this easier than ever. See Oracle Tutorial.
Comma-separate & Tab-delimited
For sets of structured data, write to text files in comma-separated values (CSV) or tab-delimited values. For example a list of people with rows for each person, and columns for name, phone number, and email address.
While reading/writing such files is easy enough to program yourself, I suggest using an established library to eliminate the drudgery, avoid bugs, and save yourself some time. There are a few such libraries written in Java.
My favorite is the Apache Commons CSV project. This library makes easy work of the chore of reading/writing such files. Despite the name, this library supports tab-delimited as well as comma-separated formats. I've written a few Answers here on Stack Overflow showing how to use this library, as you can see here, here, and here.
By the way, plain old ASCII defines a few character positions explicitly for delimiting in data files, with four levels of grouping (document, group, record/row, and field). Unicode, of course, inherits these from ASCII as code points. I am puzzled why these have remained so obscure and so infrequently used. Seems much more logical to me than using commas and tabs which may well exist inside the data payload.
Serialization
You can write out the data values stored within an object. This is called serialization. Java has a serialization facility built-in, but be sure to study up on the details.
To more simply write out an object’s values and later read them back in to reconstitute an object, I have enjoyed using the Simple XML Serialization project. This works well for relatively simple needs, and is aimed at the situation where you want the structure of a class to drive the process of determining what to write.
Java has other XML binding facilities both built-in and third-party. These are much more powerful in their flexibility. They are especially good for when you want to define and verify the XML structure in a rigid fashion such as defining a XML DTD or XML Schema against which to validate the data and perhaps even generate the Java class in which to represent the data.
Embedded database
For more complicated data, use an embedded relational database.
The SQLite database is bundled with many platforms. This is a C-based library, not pure Java. As the name indicates, SQLite is indeed quite “lite“, lacking rigid data types and many other common database features. SQLite is meant to be an alternative to writing text files than as a competitor to more serious databases. It is a great product if your needs fit the sweet-spot of its capabilities.
My first choice for an embedded database would be H2 Database Engine. Built in pure Java. Can be run inside your app, or separately as a server (you choice). Has sophisticated relational database features. Has been around for years, often updated, and is well-worn. The principal author has much experience in the field.

Solution to read data from NeXT/Apple typedstream data, little endian, version 4, system 1000

An application that I am currently working on contains several files of the above mentioned type. These files are created using NSArchiver from an legacy framework called OpenStep.
If I am correct than this is a data format which was used pre and begin OS/X and is now replaced by NSKeyedArchiver. Although I think current OS/X implementations of NSUnArchiver can still read this older format.
When opening these files there are some contents which can be read by humans like dataformats such as BlockArray, NSObject etc. The rest is binary data which does not make sense.
I have to be able to retrieve information from these files to process further in a Java based application. I would love to know what you would advise me to do in this case so that I am able to use the information in these files.
A side note:
The GNUSTEP implementation does not support this typedstream data.
My main application is written in Java.
Preferably a solution which does not require me to develop on the OS/X platform.
Solution should run on Windows platform.

How do I export/import a java object(JList) to/from a java program?

I am writing a java program and I would like for it to at startup make a JList(of strings) from a pre-made file(text file?) and then do changes here and there during the program and then re-save it at the end to be accessed again later.
I am new to java and it seems like there are many ways to read and write files and I don't known which way is best.
Is there a general way to save java objects to files that I can re-use later on, maybe with strings?
http://www.javapractices.com/topic/TopicAction.do?Id=42
http://www.java-samples.com/showtutorial.php?tutorialid=330
http://www.caveofprogramming.com/java/java-file-reading-and-writing-files-in-java/
This link provides you different types of reading and writing text files
And there is no general way to write an object to a file, as the object can have any structure. So we have to write the implementation for the way a file is written in java.

User Profiles using properties in Java

I am making a math game in Java and I want to create the ability for the user to create a local account (or log in to an existing one), which would have a unique properties file. How would I do this?
You have a couple of options to look into. Java comes with the necessary libraries with which you can create, open, read and write to files. Using the File class, you could create an account file, for instance "User1.properties", and save the information in an easy to parse format. If you're looking to go one further, you can look into using XML or JSON, which are commonly used formats for saving information in this way. Here's some helpful links to get you started.
Using files in Java
Using XML in Java
Using JSON in Java
Another option you have available is to use a database in a similar fashion to websites. The type of database you use is up to you, although MySQL is an example of one commonly used database. Once again, here is a link to help you get started with MySQL in Java.
Regardless of what you use, you will need to take the username and password provided (or whatever combination of login credentials you would like your system to use), and compare them with those stored in your file or database.

Categories