Daniel have worked with modular RCP platforms as are NetBeans and Eclipse, developed support for proprietary technology which is processing huge volumes of XML data. Now is working on Register of traffic accidents(J2EE application build on Websphere) for Ministry of Interior of the Slovak Republic. Daniel has posted 9 posts at DZone. You can read more from them at their website. View Full User Profile

Insert Formatted Strings into Your Java Code

06.03.2010
| 6196 views |
  • submit to reddit

Are you tired of quoting when inserting formatted text as a String value in to your Java source code?

Let's have a look at this gadget, Clipboard Modificator.

Example:

<Message>
Hello world
</Message>

 In Java code as a String value:

String xmlMessage = 
"<Message>\n"+
" Hello world \n"+
"</Message>";

 It isa free plugin to the NetBeans IDE and its called Clipboard Modificator.

  • Latest version can do the both ways, and even lets you to specify your own regular expression.

    See more informations on:

    http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp;jsessionid=5a53df7647a680b37c81abe6dfa6?pluginid=25439

  • 4
    Your rating: None Average: 4 (2 votes)
    Published at DZone with permission of its author, Daniel Kec.

    (Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

    Comments

    Senthil Balakrishnan replied on Thu, 2010/06/03 - 6:52am

    In my experience it takes more time than it look to be. Should be a good feature for developers.

    Thanks,

    Sen

    Cristian Vasile... replied on Thu, 2010/06/03 - 1:24pm

    IntelliJ IDEA does the escape automatically every time you paste inside a string.

    Erik Clairiot replied on Thu, 2010/06/03 - 3:37pm

    Eclipse either (but not by default, configuration required)

    Chmouel Boudjnah replied on Thu, 2010/06/03 - 6:31pm in response to: Erik Clairiot

    what is the configuration I am wondering!

    Gervais Blaise replied on Fri, 2010/06/04 - 2:17am in response to: Erik Clairiot

    Nice, Can you tell us more about how to configure eclipse to do that ?

    Daniel Kec replied on Fri, 2010/06/04 - 5:39am in response to: Cristian Vasile Mocanu

    You are right, idea does that, i wonder why NetBeans IDE still missing that

    Erik Clairiot replied on Fri, 2010/07/02 - 3:17pm in response to: Chmouel Boudjnah

    Sorry, I didn't check this post again.

    For Eclipse configuration :

    - preferences -> Java -> Editor -> Typing -> Escape text when pasting into literals

    Comment viewing options

    Select your preferred way to display the comments and click "Save settings" to activate your changes.