Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

constructor is invisible? - jdom - format class

Thread view: 
mdx - 13 Nov 2005 21:00 GMT
Hi all

I am trying to ouput some XML. I read the XMLOutputter
API(http://www.jdom.org/docs/apidocs/org/jdom/output/XMLOutputter.html),
and the contructor indicated that I can pass in a Format object.

So, I try to do this

        Format XMLOutFormat = new Format();
        XMLOutFormat.setIndent("   ");
        XMLOutFormat.setLineSeparator("\n");
       
        outputter = new XMLOutputter(XMLOutFormat);

However, the compiler says "the constructor Format()" is not visible.
How do I instantiate a Format object then? Please advise.

Thanks.

Howard
zero - 13 Nov 2005 21:19 GMT
mdx <j8shen@gmail.com> wrote in news:OPNdf.233$KP5.41061
@news20.bellglobal.com:

> Hi all
>
[quoted text clipped - 5 lines]
>
>           Format XMLOutFormat = new Format();

First off, you don't want to use XMLOutFormat as variable name.  Variable
names should not start with a capital letter, to avoid confusion.  Class
names start with a capital.

>           XMLOutFormat.setIndent("   ");
>           XMLOutFormat.setLineSeparator("\n");
[quoted text clipped - 7 lines]
>
> Howard

Format does not have a public constructor, so you need one of the
"factory" methods getCompactFormat(), getPrettyFormat() or getRawFormat
().

For example:

Format format = Format.getRawFormat();
format.setIndent("   ");
format.setLineSeparator("\n");
XMLOutPutter xmlOut = new XMLOutPutter(format);

Note that the setIndent and setLineSeparator return a Format object as
well, so you can use the compact notation:

Format.getRawFormat().setIndent("   ").setLineSeparator("\n");
mdx - 13 Nov 2005 21:27 GMT
appreciate the help!..

Howard

> mdx <j8shen@gmail.com> wrote in news:OPNdf.233$KP5.41061
> @news20.bellglobal.com:
[quoted text clipped - 43 lines]
>
> Format.getRawFormat().setIndent("   ").setLineSeparator("\n");


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.