Archive

Archive for March, 2010

Content Management System

March 31, 2010 Leave a comment
Categories: CMS Tags:

Java Split String with Pipe (|) Parameter

March 31, 2010 1 comment

Problem: Try to split String which is having delimiter as pipe(|)

public class TestSplit
{
  public static void main( String[] args )
  {
     String DELIMETER = "@";
    // String DELIMETER = "|";
    

    String line = "field1" + DELIMETER + "field2";

    String[] tempList = line.split( DELIMETER );
    int sizeOfArray = tempList.length;

    System.out.println( "sizeOfArray==>" + sizeOfArray );

    for( int i = 0; i < tempList.length; i++ ) {
      System.out.println( i + "==>" + tempList[i] );
    }
  }
}

Why Pipe(|) wont work as delimeter?

Java Syntax
String[] split(String regex)
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
Logical operators
X|Y Either X or Y

-o-

Apache POI – Maven – WorkbookFactory Class issue

March 11, 2010 Leave a comment

Problem: Failed to find WorkbookFactory class while working with Apache POI

Solution: Use correct maven configuration and it will be resolved.

   <dependency>
        <groupId>org.apache.poi</groupId>
	<artifactId>poi</artifactId>
	<version>3.6</version>
    </dependency>   
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.5-beta5</version>
    </dependency> 

Categories: Apache POI Tags:

SCRUM in Under 10 Minutes

March 10, 2010 Leave a comment

This is best video on Scrum….Check it up

Video produced by Axosoft, a software company that develops the scrum software, OnTime.
http://www.axosoft.com/ontime/videos/scrum

http://www.youtube.com/watch?v=Q5k7a9YEoUI

Agile Testing

March 10, 2010 Leave a comment
Categories: Software Testing Tags:

The code for the static initializer is exceeding the 65535 bytes limit

March 10, 2010 Leave a comment

Come across some auto generated code. It is showing following error….. : )

The code for the static initializer is exceeding the 65535 bytes limit

How to fix it?

Solution: Make sure that it wont happen or split the code .. : )

Categories: Core Java

Phone Number Validation / Formatting

March 8, 2010 Leave a comment

Problem: How to format phone numbers for different countries?

We dont have any ready to use library at this time. We need to develop our own library.

International Country Codes for phone lines is provided by ITU.
http://www.itu.int/publ/T-SP-E.164D-2009/en

Reference: http://www.answers.com/topic/telephone-number-1
-o-

BT Cotton / Crops are good for all

March 8, 2010 Leave a comment

Scientist Name: Polimetla Ananda Kumar
bt_cotton_is_good_for_all_eenadu_mar082010

Categories: News Feeds Tags:

Restlet – Read HTTP Headers

March 4, 2010 Leave a comment

Problem: How to read HTTP Headers in Restlet? Also we need to get Date from HTTP Headers.

Series<Parameter> headers = (Series<Parameter>) getRequest().getAttributes().get("org.restlet.http.headers");
Set<String> headerNames = headers.getNames();
for(String headerName:headerNames)
{
	System.out.println( "name==>"+headerName+" value==>"+ headers.getFirstValue(headerName));
}

Output:

name==>accept-encoding value==>gzip,deflate
name==>connection value==>keep-alive
name==>accept-language value==>en-us,en;q=0.5
name==>host value==>localhost:8080
name==>accept-charset value==>ISO-8859-1,utf-8;q=0.7,*;q=0.7
name==>user-agent value==>Mozilla/5.0 (Windows; U; Windows NT 4.x; en-US; rv:1.x.x.x) Gecko/23423423 Firefox/2.4.6
name==>accept value==>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
name==>keep-alive value==>300

Observation: Date is missing when tried from Browser.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

When tried from Restlet Client, it is working.

Form attributes = new Form();  
attributes.add( "message.date", "Mar-03-2010 10:30 AM" );
request.getAttributes().put( "org.restlet.http.headers", attributes );

Final Solution:
It is difficult to depend on HTTP Headers when clients are from Flex and other applications.
Easiest way is add Query String parameter like &date=123123123123123

Reference:
http://www.restlet.org/documentation/1.0/faq
http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/130-restlet.html
http://en.wikipedia.org/wiki/List_of_HTTP_headers

Setting JasperReports document properties

March 1, 2010 Leave a comment

Problem Statement:  How to set JasperReports document properties?

Solution:

net.sf.jasperreports.engine.JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
// Properties Begin
exporter.setParameter( JRPdfExporterParameter.METADATA_TITLE, "Title of the Document" );
exporter.setParameter( JRPdfExporterParameter.METADATA_AUTHOR, "Author of the document" );
exporter.setParameter( JRPdfExporterParameter.METADATA_SUBJECT, "Subject line of document" );
exporter.setParameter( JRPdfExporterParameter.METADATA_KEYWORDS, "Key Words to search down the line" );
exporter.setParameter( JRPdfExporterParameter.METADATA_CREATOR, "Application Name, which created this document." );
exporter.setParameter( JRPdfExporterParameter.OUTPUT_FILE_NAME, "Used when click on save button from client" );


//This used to set document passwords and compression and encryption
JRProperties.setProperty( JRPdfExporterParameter.PROPERTY_USER_PASSWORD, "password1" );
JRProperties.setProperty( JRPdfExporterParameter.PROPERTY_OWNER_PASSWORD, "password2" );
JRProperties.setProperty( JRPdfExporterParameter.PROPERTY_ENCRYPTED, true );
JRProperties.setProperty( JRPdfExporterParameter.PROPERTY_COMPRESSED, true );


ByteArrayOutputStream out  = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
exporter.exportReport();

Reference: Check
1. Jasper Reports API: http://jasperreports.sourceforge.net/api/index.html
2. Jasper Reports Forum
3. Samples: http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/samples.html

-o-

Follow

Get every new post delivered to your Inbox.