org.wicketstuff.rest.resource.urlsegments
Class AbstractURLSegment

java.lang.Object
  extended by org.apache.wicket.util.string.StringValue
      extended by org.wicketstuff.rest.resource.urlsegments.AbstractURLSegment
All Implemented Interfaces:
Serializable, IClusterable
Direct Known Subclasses:
FixedURLSegment, MultiParamSegment, ParamSegment

public abstract class AbstractURLSegment
extends StringValue

Base class to contain the informations of the segments that compose the URL used to map a method. It's used to use simple segments with no path parameters.

Author:
andrea del bene
See Also:
Serialized Form

Field Summary
static MetaPattern REGEXP_BODY
          MetaPattern to identify the content of a regular expression.
static MetaPattern REGEXP_DECLARATION
          MetaPattern to identify the declaration of a regular expression.
static MetaPattern SEGMENT_PARAMETER
          MetaPattern to identify a path parameter inside a segment (i.e.
 
Method Summary
abstract  int calculateScore(String segment)
          This method checks if a given string is compatible with the current segment.
static String getActualSegment(String fullSegment)
          Get the segment value without optional matrix parameters.
 MetaPattern getMetaPattern()
          Getter method for segment MetaPattern.
static Map<String,String> getSegmentMatrixParameters(String fullSegment)
          Extract matrix parameters from the segment in input.
protected abstract  MetaPattern loadMetaPattern()
          Method invoked to load the MetaPattern for the current segment.
static AbstractURLSegment newSegment(String segment)
          Factory method to create new instances of AbstractURLSegment.
abstract  void populatePathVariables(Map<String,String> variables, String segment)
          With this method every segment contributes to extract path parameters from the current request URL.
 
Methods inherited from class org.apache.wicket.util.string.StringValue
afterFirst, afterLast, beforeFirst, beforeLast, equals, hashCode, isEmpty, isNull, repeat, repeat, replaceAll, to, toBoolean, toBoolean, toBooleanObject, toChar, toChar, toCharacter, toDouble, toDouble, toDoubleObject, toDuration, toDuration, toEnum, toEnum, toEnum, toInt, toInt, toInteger, toLong, toLong, toLongObject, toOptional, toOptionalBoolean, toOptionalCharacter, toOptionalDouble, toOptionalDuration, toOptionalEnum, toOptionalInteger, toOptionalLong, toOptionalString, toOptionalTime, toString, toString, toTime, toTime, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

REGEXP_BODY

public static final MetaPattern REGEXP_BODY
MetaPattern to identify the content of a regular expression.


REGEXP_DECLARATION

public static final MetaPattern REGEXP_DECLARATION
MetaPattern to identify the declaration of a regular expression.


SEGMENT_PARAMETER

public static final MetaPattern SEGMENT_PARAMETER
MetaPattern to identify a path parameter inside a segment (i.e. "{paramName:regexp}")

Method Detail

loadMetaPattern

protected abstract MetaPattern loadMetaPattern()
Method invoked to load the MetaPattern for the current segment.

Returns:
the MetaPattern for the current segment.

newSegment

public static AbstractURLSegment newSegment(String segment)
Factory method to create new instances of AbstractURLSegment.

Parameters:
segment - The content of the new segment.
Returns:
the new instance of AbstractURLSegment.

calculateScore

public abstract int calculateScore(String segment)
This method checks if a given string is compatible with the current segment.

Parameters:
segment -
Returns:
an integer positive value if the string in input is compatible with the current segment, 0 otherwise. Segments of type FixedURLSegment have the priority over the other types of segment. That's why positive matches has a score of 2 if the method is invoked on a FixedURLSegment, while it returns 1 for the other types of segment.

getActualSegment

public static String getActualSegment(String fullSegment)
Get the segment value without optional matrix parameters. For example given the following value 'segment;parm=value', the function returns 'segment'.

Parameters:
fullSegment -
Returns:
the value of the segment without matrix parameters.

getSegmentMatrixParameters

public static Map<String,String> getSegmentMatrixParameters(String fullSegment)
Extract matrix parameters from the segment in input.

Parameters:
fullSegment - the segment in input.
Returns:
a map containing matrix parameters.

populatePathVariables

public abstract void populatePathVariables(Map<String,String> variables,
                                           String segment)
With this method every segment contributes to extract path parameters from the current request URL.

Parameters:
variables - the Map object containing the extracted parameters.
segment - the value of the current segment.

getMetaPattern

public final MetaPattern getMetaPattern()
Getter method for segment MetaPattern.



Copyright © 2013–2014. All rights reserved.