org.hd.d.pg2k.svrCore.props
Class GenProps.ClassifiedAd

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.props.GenProps.ClassifiedAd
All Implemented Interfaces:
java.io.ObjectInputValidation, java.io.Serializable, MemoryTools.Internable
Enclosing class:
GenProps

public static final class GenProps.ClassifiedAd
extends java.lang.Object
implements java.io.Serializable, java.io.ObjectInputValidation, MemoryTools.Internable

Class holding details of one classified advertisement; immutable, serialisable. We assume that the on-the-wire format for members is reasonably efficient, especially if the transport layer includes compression such as ZIP.

See Also:
Serialized Form

Field Summary
 java.lang.String code
          HTML code as 7-bit ASCII; non-null, non-zero length.
 java.lang.String countries
          Country code; comma-separated list of lower-case ccTLD codes or null if none.
 long end
          Start time (+ve UTC ms greater than 'start') or zero if no end time.
 java.lang.String lang
          Language/locale filter; two-letter lower-case language code or null if none.
static int MAX_AD_CHARACTERS
          Maximum HTML code length in bytes/characters, as per SimpleAs; strictly positive.
private  java.util.regex.Pattern pattern
          Private cache of compiled regex; null until first use.
 java.lang.String regex
          Valid case-sensitive regular expression to match a substring of a URI path, never null nor empty.
private static long serialVersionUID
          Unique serialisation UID.
 long start
          Start time (+ve UTC ms) or zero if no start time.
 
Constructor Summary
GenProps.ClassifiedAd(java.lang.String HTMLCode, java.lang.String URIregex, long start, long end, java.lang.String language, java.lang.String ccTLDs)
          Construct new classified ad details.
 
Method Summary
 boolean equals(java.lang.Object o)
          Equality depends on all fields.
 java.util.regex.Pattern getPattern()
          Get compiled regex; never null.
 int hashCode()
          Hash depends on the regex and the end date as good/quick sources of variability.
protected  java.lang.Object readResolve()
          Deserialise: validate and eliminate duplicates coming off the wire.
 void validateObject()
          Validate fields/state.
 boolean wrongCountry(GeoUtils.CCTLD visitorCcTLD)
          Returns true if the supplied (visitor's) country is inappropriate for this ad.
 boolean wrongLanguage(java.util.Locale visitorLocale)
          Returns true if the supplied (visitor's) locale is inappropriate for this ad.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regex

public final java.lang.String regex
Valid case-sensitive regular expression to match a substring of a URI path, never null nor empty.


pattern

private transient volatile java.util.regex.Pattern pattern
Private cache of compiled regex; null until first use. Created on first use; not serialised.

Never set null once non-null.

Marked volatile for thread-safe lock-free access,


code

public final java.lang.String code
HTML code as 7-bit ASCII; non-null, non-zero length.


MAX_AD_CHARACTERS

public static final int MAX_AD_CHARACTERS
Maximum HTML code length in bytes/characters, as per SimpleAs; strictly positive.

See Also:
Constant Field Values

start

public final long start
Start time (+ve UTC ms) or zero if no start time.


end

public final long end
Start time (+ve UTC ms greater than 'start') or zero if no end time.


lang

public final java.lang.String lang
Language/locale filter; two-letter lower-case language code or null if none.


countries

public final java.lang.String countries
Country code; comma-separated list of lower-case ccTLD codes or null if none.


serialVersionUID

private static final long serialVersionUID
Unique serialisation UID.

See Also:
Constant Field Values
Constructor Detail

GenProps.ClassifiedAd

public GenProps.ClassifiedAd(java.lang.String HTMLCode,
                             java.lang.String URIregex,
                             long start,
                             long end,
                             java.lang.String language,
                             java.lang.String ccTLDs)
Construct new classified ad details.

Parameters:
HTMLCode - HTML code as 7-bit ASCII; non-null, non-zero length
URIregex - valid regular expression to match a substring of a URI path; never null nor empty
Method Detail

getPattern

public java.util.regex.Pattern getPattern()
Get compiled regex; never null.


wrongLanguage

public boolean wrongLanguage(java.util.Locale visitorLocale)
Returns true if the supplied (visitor's) locale is inappropriate for this ad. If the lang value is null then this returns false. Else if the visitor's locale/language is null (unknown) then this returns true. Else this returns true iff the visitor's locale language matches lang.


wrongCountry

public boolean wrongCountry(GeoUtils.CCTLD visitorCcTLD)
Returns true if the supplied (visitor's) country is inappropriate for this ad. If the countries list is null then this returns false. Else if the visitor's ccTLD (country code) is null (unknown) then this returns true. Else this returns true iff the visitor's ccTLD is found on our countries list.


equals

public boolean equals(java.lang.Object o)
Equality depends on all fields.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Hash depends on the regex and the end date as good/quick sources of variability.

Overrides:
hashCode in class java.lang.Object

validateObject

public void validateObject()
                    throws java.io.InvalidObjectException
Validate fields/state. Called in the constructor and possibly after de-serialising.

Specified by:
validateObject in interface java.io.ObjectInputValidation
Throws:
java.io.InvalidObjectException

readResolve

protected java.lang.Object readResolve()
Deserialise: validate and eliminate duplicates coming off the wire.

Returns:
identical, de-duped, non-null instance

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.