The data structures provided by the Java utility package are very
powerful and perform a wide range of functions. These data structures
consist of the following interface and classes −
Labels
.
Search Your Article
Total Pageviews
Tuesday, January 17, 2017
Java - Collections Framework
Prior to Java 2, Java provided ad hoc classes such as Dictionary, Vector, Stack, and Properties
to store and manipulate groups of objects. Although these classes were
quite useful, they lacked a central, unifying theme. Thus, the way that
you used Vector was different from the way that you used Properties.
The collections framework was designed to meet several goals, such as −
The collections framework was designed to meet several goals, such as −
Java - Generics
It would be nice if we could write a single sort method that could
sort the elements in an Integer array, a String array, or an array of
any type that supports ordering.
Java - Serialization
Java provides a mechanism, called object serialization where an
object can be represented as a sequence of bytes that includes the
object's data as well as information about the object's type and the
types of data stored in the object.
Java - Networking
The term network programming refers to writing programs that
execute across multiple devices (computers), in which the devices are
all connected to each other using a network.
Java - Sending Email
To send an e-mail using your Java Application is simple enough but to start with you should have JavaMail API and Java Activation Framework (JAF) installed on your machine.
Java - Multithreading
Java is a multi-threaded programming language which means we
can develop multi-threaded program using Java. A multi-threaded program
contains two or more parts that can run concurrently and each part can
handle a different task at the same time making optimal use of the
available resources specially when your computer has multiple CPUs.
Java - Applet Basics
An applet is a Java program that runs in a Web browser. An
applet can be a fully functional Java application because it has the
entire Java API at its disposal.
There are some important differences between an applet and a standalone Java application, including the following −
There are some important differences between an applet and a standalone Java application, including the following −
Java - Documentation Comments
The Java language supports three types of comments −
Sr.No. | Comment & Description |
---|---|
1 | /* text */ The compiler ignores everything from /* to */. |
2 | //text |
JAVA Questions and Answers
JAVA Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews.
This section provides a useful collection of sample Interview Questions
and Multiple Choice Questions (MCQs) and their answers with
appropriate explanations.
Java - Useful Resources
The following resources contain additional information on Java. Please use them to get more in-depth knowledge on this topic.
Discuss Java
Java is a high-level programming language originally developed by Sun
Microsystems and released in 1995. Java runs on a variety of platforms,
such as Windows, Mac OS, and the various versions of UNIX. This
tutorial gives a complete understanding of Java.
This reference will take you through simple and practical approaches while learning Java Programming language.
This reference will take you through simple and practical approaches while learning Java Programming language.
Java JDBC - Programming Examples
Learn how to use JDBC in Java programming. Here are most commonly used examples −
Java Regular Expression - Programming Examples
Learn how to use regular expression in Java programming. Here are most commonly used examples −
JAVA Questions and Answers
JAVA Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews.
This section provides a useful collection of sample Interview Questions
and Multiple Choice Questions (MCQs) and their answers with
appropriate explanations.
Java - Useful Resources
The following resources contain additional information on Java. Please use them to get more in-depth knowledge on this topic.
Discuss Java
Java is a high-level programming language originally developed by Sun
Microsystems and released in 1995. Java runs on a variety of platforms,
such as Windows, Mac OS, and the various versions of UNIX. This
tutorial gives a complete understanding of Java.
This reference will take you through simple and practical approaches while learning Java Programming language.
This reference will take you through simple and practical approaches while learning Java Programming language.
Java XML Overview
What is XML?
XML is a simple text based language which was designed to store and transport data in plain text format. It stands for Extensible Markup Language. Following are some of the salient features of XML.Java XML Parsers
What is XML Parsing?
Parsing XML refers to going through XML document to access data or to modify data in one or other way.Java DOM Parser - Overview
The Document Object Model is an official recommendation of the World
Wide Web Consortium (W3C). It defines an interface that enables programs
to access and update the style, structure,and contents of XML
documents. XML parsers that support the DOM implement that interface.
Java DOM Parser - Parse XML Document
Steps to Using DOM
Following are the steps used while parsing a document using DOM Parser.- Import XML-related packages.
- Create a DocumentBuilder
- Create a Document from a file or stream
Java DOM Parser - Query XML Document
Demo Example
Here is the input xml file we need to query:<?xml version="1.0"?> <cars>
Java DOM Parser - Create XML Document
Demo Example
Here is the XML we need to create:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars><supercars company="Ferrari">
Java DOM Parser - Modify XML Document
Demo Example
Here is the input xml file we need to modify:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars>
Java SAX Parser - Overview
SAX (the Simple API for XML) is an event-based parser for xml
documents.Unlike a DOM parser, a SAX parser creates no parse tree.
SAX is a streaming interface for XML, which means that applications
using SAX receive event notifications about the XML document being
processed an element, and attribute, at a time in sequential order
starting at the top of the document, and ending with the closing of the
ROOT element.
Java SAX Parser - Parse XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393">
Java SAX Parser - Query XML Document
Demo Example
Here is the input text file we need to Query for rollno: 393<?xml version="1.0"?> <class> <student rollno="393">
Java SAX Parser - Create XML Document
It is better to use StAX parser for creating XML than using SAX parser. Please refer the Java StAX Parser section for the same.
Java SAX Parser - Modify XML Document
Demo Example
Here is the input xml file we need to Modify by appending <Result>Pass<Result/>at the end of </marks> tag
<?xml version="1.0"?> <class>
Java JDOM Parser - Overview
JDOM is an open source, java based library to parse XML document and it
is typically java developer friendly API. It is java optimized, it uses
java collection like List and Arrays. It works with DOM and SAX APIs and
combines the best of the two. It is of low memory footprint and is
nearly as fast as SAX.
Java JDOM Parser - Parse XML Document
Steps to Using JDOM
Following are the steps used while parsing a document using JDOM Parser.- Import XML-related packages.
- Create a SAXBuilder
Java JDOM Parser - Query XML Document
Demo Example
Here is the input xml file we need to query:<?xml version="1.0"?> <cars> <supercars company="Ferrari">
Java JDOM Parser - Create XML Document
Demo Example
Here is the XML we need to create:<?xml version="1.0" encoding="UTF-8"?> <cars> <supercars company="Ferrari">
Java JDOM Parser - Modify XML Document
Demo Example
Here is the input text file we need to modify:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars> <supercars company="Ferrari">
Java StAX Parser - Overview
StAX is a JAVA based API to parse XML document in a similar way as
SAX parser does. But there are two major difference between the two APIs
Java StAX Parser - Parse XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393"> <firstname>dinkar</firstname>
Java StAX Parser - Query XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393">
Java StAX Parser - Create XML Document
Demo Example
Here is the XML we need to create:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars><supercars company="Ferrari">
Java StAX Parser - Modify XML Document
Demo Example
Here is the XML we need to modify:<?xml version="1.0"?> <class> <student rollno="393">
Java XPath Parser - Overview
The XPath is an official recommendation of the World Wide Web
Consortium (W3C). It defines a language to find information in an XML
file. It is used to traverse elements and attributes of an XML document.
XPath provides various type of expressions which can be used to enquire
relevant information from the XML document.
Java XPath Parser - Parse XML Document
Steps to Using XPath
Following are the steps used while parsing a document using XPath Parser.- Import XML-related packages.
- Create a DocumentBuilder
Java XPath Parser - Query XML Document
Demo Example
Here is the input text file we need to query:<?xml version="1.0"?> <class>
Java XPath Parser - Create XML Document
XPath parser is used to to navigate XML Document only. It is better
to use DOM parser for creating XML. Please refer the Java DOM Parser
section for the same.
Java XPath Parser - Modify XML Document
XPath parser is used to to navigate XML Document only. It is
better to use DOM parser for modifying XML. Please refer the Java DOM
Parser section for the same.
Java DOM4J Parser - Overview
DOM4J is an open source, java based library to parse XML document and it
is highly flexible, high-performance, and memory-efficient API. It is
java optimized, it uses java collection like List and Arrays. It works
with DOM, SAX, XPath and XSLT. It can parse large XML document with
very low memory footprint.
Java DOM4J Parser - Parse XML Document
Steps to Using DOM4J
Following are the steps used while parsing a document using DOM4J Parser.Java DOM4J Parser - Query XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393">
Java DOM4J Parser - Create XML Document
Demo Example
Here is the XML we need to create:<?xml version="1.0" encoding="UTF-8"?> <cars> <supercars company="Ferrari">
Java DOM4J Parser - Modify XML Document
Demo Example
Here is the XML we need to modify:<?xml version="1.0"?> <class> <student rollno="393">
Java XML Questions and Answers
Java XML Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews.
This section provides a useful collection of sample Interview Questions
and Multiple Choice Questions (MCQs) and their answers with
appropriate explanations.
Java XML Useful Resources
If you want to list down your website, book or any other resource on
this page then please contact at webmaster@tutorialspoint.com
JasperReports - Getting Started
What is a Report
A report is a meaningful, well-defined, and summarized presentation of information. Usually, the routine activities are automated and data summarized into a decision-supporting "Reports". Reports represent usual messy data into charts, graphs, and other forms of graphical representations.JasperReports - Environment Setup
JasperReports is a pure Java library and not a standalone
application. It cannot run on its own, hence it needs to be embedded
into another client or server-side Java application. As it is Java
based, it can be run on any platform that supports Java (JDK 1.3 and
above).
JasperReports - Life Cycle
The main purpose of JasperReports is to create page oriented, ready
to print documents in a simple and flexible manner. The following flow
chart depicts a typical work flow while creating reports.
JasperReports - Designs
The JRXML templates (or JRXML files) in JasperReport are standard XML
files, having an extension of .jrxml. All the JRXML files contain tag
<jasperReport>, as root element. This in turn contains many
sub-elements (all of these are optional).
JasperReports - Compiling Report Design
We have generated the JasperReport template (JRXML file) in the
previous chapter. This file cannot be used directly to generate reports.
It has to be compiled to JasperReport' native binary format, called Jasper file. On compiling, we transform JasperDesign object into JasperReport object −
JasperReports - Filling Reports
The main purpose of any reporting tool is to produce high quality
documents. Report filling process helps reporting tool to achieve this
by manipulating sets of data.
The main inputs required for report-filling process are −
The main inputs required for report-filling process are −
Jasper Report - View & Print Reports
The output of the report filling process JasperPrint objects
can be viewed using a built-in viewer component, or printed, or exported
to more popular document formats like PDF, HTML, RTF, XLS, ODT, CSV, or
XML. Viewing and printing of the Jasper documents will be discussed in
this chapter and exporting will be discussed in the next chapter i.e. 'Export Reports.'
JasperReports - Exporting Reports
We have seen in the previous chapter, how to print and view a
JasperReport generated document. Here, we shall see how to transform or
export these reports into other formats such as PDF, HTML, and XLS.
Reports Parameters
The main input for filling a report are − report template,
parameters, and data sources. This chapter will describe the parameters
and in the next chapter we will discuss the data sources.
Report Data Sources
Datasources are structured data container. While generating the
report, JasperReports engine obtains data from the datasources. Data can
be obtained from the databases, XML files, arrays of objects, and
collection of objects.
Reports Fields
Report fields are elements, which represent mapping of data between
datasource and report template. Fields can be combined in the report
expressions to obtain the desired output. A report template can contain
zero or more <field> elements.
Report Expression
Report expressions are the powerful features of JasperReports, which
allow us to display calculated data on a report. Calculated data is the
data that is not a static data and is not specifically passed as a
report parameter or datasource field.
Report Variables
Report variables are special objects built on top of the report expression.
Report variables simplify the following tasks −
Report variables simplify the following tasks −
Report Sections
We discussed the structure of a simple report template in the chapter Getting Started.
On similar lines, JasperReports structures the report template into
multiple sections. Sections are portions of the report that have a
specified height and can contain report objects like lines, rectangles,
images, or text fields.
Report Groups
Groups in JasperReports help to organize data on report in a logical
manner. A report group represents a sequence of consecutive records in
the data source, which have something in common, such as the value of a
certain report fields.
Report Fonts
A report contains text elements and each of these can have its own font settings. These settings can be specified using the <font>
tag available in the <textElement> tag. A report can define a
number of fonts.
Unicode Support
In JasperReports, working with texts needs some dedicated tools to
process both the character representations and the text formatting
properties. Any text can be considered as a character sequence with a
particular representation structure.
Report Styles
JasperReports has a feature <style> which helps to control text
properties in a report template. This element is a collection of style
settings declared at the report level. Properties like foreground color,
background color, whether the font is bold, italic, or normal, the font
size, a border for the font, and many other attributes are controlled
by <style> element. Styles can extend other styles, and add to, or
override properties of the parent style as well.
Report Scriptlets
We have seen in our previous chapters, data displayed on the report
is usually fetched from report parameters and report fields. This data
can be processed using the report variables and their expressions. There
are situations when a complex functionality cannot be achieved easily
using report expressions or variables.
Create SubReports
Subreports are one of the nice features of the JasperReports. This
feature allows incorporating a report within another report, that is,
one report can be a subreport of another. Subreports help us keep report
designs simple, as we can create many simple reports and encapsulate
them into a master report.
Creating Charts
Earlier people had to rely on scriptlets to gather the chart data and
render the chart using an image element in the report template.
JasperReports makes it simple now, as it has a built-in support for
charts using the new chart component.
JasperReports - Crosstabs
Crosstab (cross-tabulation) reports are the reports containing tables
that arrange data across rows and columns in a tabular form. Crosstab
object is used for inserting a crosstab report within the main report.
Crosstabs can be used with any level of data (nominal, ordinal,
interval, or ratio), and usually display the summarized data, contained
in the report variables, in the form of a dynamic table. Variables are
used to display aggregate data such as sums, counts, average values.
JasperReports - Internationalization
Sometimes, we need reports in different languages. Writing the same
report for each different language implies a lot of redundant work. Only
pieces of text differing from language to language should be written
separately, and loaded into text elements at runtime, depending on
locale settings.
JasperReports - Useful Resources
The following resources contain additional information on
JasperReports. Please use them to get more in-depth knowledge on this
topic.
Discuss JasperReports
JasperReports is an open source java reporting engine. JasperReports is a
Java class library, and it is meant for those Java developers who need
to add reporting capabilities to their applications. This simple and
user-friendly tutorial covers almost all the basics of JasperReports
that a beginner should know.
Jackson - Overview
Jackson is a simple Java-based library to serialize Java objects to JSON and vice versa.
Features of Jackson
Jackson - Environment Setup
This chapter describes how to set up the Jackson environment on your system.
Try-It Online Option
Jackson - First Application
Before going into the details of the Jackson library, let us see an application in action.
Jackson Example
Jackson - ObjectMapper Class
ObjectMapper is the main actor class of Jackson library. ObjectMapper
class provides functionalities to convert Java objects to matching JSON
constructs and vice versa. It uses instances of JsonParser and
JsonGenerator for implementing actual reading/writing of JSON.
Jackson - Object Serialization
To understand object serialization in detail, let us serialize a Java
object to a JSON file and then read that JSON file to get the object
back.
Jackson - Data Binding
Data Binding API is used to convert JSON to and from Plain Old Java
Object (POJO) using property accessor or using annotations. It is of two
types −
Jackson - Full Data Binding
Full data binding refers to mapping of JSON to any Java Object.
//Create an ObjectMapper instance ObjectMapper mapper = new ObjectMapper();
Jackson - Data Binding With Generics
In simple data binding, we have used Map class which uses String as
key and Object as a value object. Instead, we can have a concrete Java
object and type cast it to use it in JSON binding.
Consider the following example with a class UserData, a class to hold user-specific data.
Consider the following example with a class UserData, a class to hold user-specific data.
Jackson - Tree Model
The Tree Model prepares an in-memory tree representation of a JSON
document. It is the most flexible approach among the three processing
modes that Jackson supports. It is quite similar to DOM parser in XML.
Jackson - Streaming API
Streaming API reads and writes JSON content as discrete events.
JsonParser reads the data, whereas JsonGenerator writes the data.
Jackson - Useful Resources
The following resources contain additional information on Jackson
JSON Processor library. Please use them to get more in-depth knowledge
on this topic.
Discuss Jackson
ackson is a very popular and efficient Java-based library to serialize
or map Java objects to JSON and vice versa. This tutorial uses a simple
and intuitive way to explain the basic features of Jackson library API
and how to use them in practice.
iBATIS - Overview
iBATIS is a persistence framework which automates the mapping between
SQL databases and objects in Java, .NET, and Ruby on Rails. The
mappings are decoupled from the application logic by packaging the SQL
statements in XML configuration files.
iBATIS - Environment
You would have to set up a proper environment for iBATIS before
starting off with actual development work. This chapter explains how to
set up a working environment for iBATIS.
iBATIS - Create Operation
To perform any Create, Read, Update, and Delete (CRUD) operation
using iBATIS, you would need to create a Plain Old Java Objects (POJO)
class corresponding to the table. This class describes the objects that
will "model" database table rows.
iBATIS - Read Operation
We discussed, in the last chapter, how to perform CREATE operation on
a table using iBATIS. This chapter explains how to read a table using
iBATIS.
We have the following EMPLOYEE table in MySQL −
We have the following EMPLOYEE table in MySQL −
iBATIS - Update Operation
We discussed, in the last chapter, how to perform READ operation on a
table using iBATIS. This chapter explains how you can update records in
a table using iBATIS.
We have the following EMPLOYEE table in MySQL −
We have the following EMPLOYEE table in MySQL −
iBATIS - Delete Operation
This chapter describes how to delete records from a table using iBATIS.
We have the following EMPLOYEE table in MySQL −
We have the following EMPLOYEE table in MySQL −
CREATE TABLE EMPLOYEE ( id INT NOT NULL auto_increment,
iBATIS - Result Maps
The resultMap element is the most important and powerful element in
iBATIS. You can reduce up to 90% JDBC coding using iBATIS ResultMap and
in some cases, it allows you to do things that JDBC does not even
support.
iBATIS - Stored Procedures
You can call a stored procedure using iBATIS configuration. First of
all, let us understand how to create a stored procedure in MySQL.
We have the following EMPLOYEE table in MySQL −
We have the following EMPLOYEE table in MySQL −
iBATIS - Dynamic SQL
Dynamic SQL is a very powerful feature of iBATIS. Sometimes you have
to change the WHERE clause criterion based on your parameter object's
state. In such situations, iBATIS provides a set of dynamic SQL tags
that can be used within mapped statements to enhance the reusability and
flexibility of the SQL.
iBATIS - Debugging
It is easy to debug your program while working with iBATIS. iBATIS has built-in logging support and it works with the following logging libraries and searches for them in this order.
iBATIS - Hibernate
There are major differences between iBATIS and Hibernate. Both the solutions work well, given their specific domain. iBATIS is suggested in case −
iBATOR - Introduction
iBATOR is a code generator for iBATIS. iBATOR introspects one or more database tables and generates iBATIS artifacts that can be used to access the tables.
iBATIS - Useful Resources
The following resources contain additional information on iBATIS. Please use them to get more in-depth knowledge on this topic.
Discuss iBATIS
iBATIS is a persistence framework which automates the mapping between
SQL databases and objects in Java, .NET, and Ruby on Rails. iBATIS makes
it easier to build better database oriented-applications more quickly
and with less code.
Subscribe to:
Posts (Atom)