Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.litesoft.GWT.client.pavsupport.internal;

import org.litesoft.GWT.client.pavsupport.*;
import org.litesoft.commonfoundation.typeutils.*;

import com.google.gwt.place.shared.*;

/**
 * Code to support extracting a PlaceId from either a PlaceTokenizer or a Place.
 * <p/>
 * If the Place or PlaceTokenizer does NOT implement 'HasPlaceId', then class name magic is used
 * (the Place classes name must end with 'Place', and the Tokenizer(s) MUST be a static inner class of it's Place).
 */
public class PlaceIdExtractor
{
    public static String getPlaceId( PlaceTokenizer<? extends Place> pTokenizer )
    {
        return extractPlaceId( pTokenizer );
    }

    public static String getPlaceId( Place pPlace )
    {
        return extractPlaceId( pPlace );
    }

    private static String extractPlaceId( Object pObject )
    {
        if ( pObject instanceof HasPlaceId )
        {
            return Strings.noEmpty( ((HasPlaceId) pObject).getPlaceId() );
        }
        if ( pObject == null )
        {
            return null;
        }
        String s = "." + pObject.getClass().getName() + "$"; // find the String between the last '.' and the first '$'
        s = s.substring( 0, s.indexOf( '$' ) );
        s = s.substring( s.lastIndexOf( '.' ) );
        return !s.endsWith( "Place" ) ? null : Strings.noEmpty( s.substring( 0, s.length() - 5 ) );
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/pavsupport/internal/PlaceIdExtractor.java

Diff revisions: vs.
Revision Author Commited Message
939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

801 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 03:59:02 +0000
712 GeorgeS picture GeorgeS Sat 09 Jun, 2012 22:46:04 +0000

Move PAV stuff into LiteSoft