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

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

private static final class GenProps.SimpleAd
extends java.lang.Object
implements java.io.Serializable, java.io.ObjectInputValidation, MemoryTools.Internable, java.lang.Comparable<GenProps.SimpleAd>

Class holding details of one simple banner advertisement; immutable, serialisable. Weighting must be strictly positive integer; text must be non-zero-length, 7-bit printable (32--126) ASCII/HTML data, though we also allow CRLF (\r\n) for tricky JavaScript/HTML issues...

We assume that the on-the-wire format for members is reasonably efficient, especially if the transport layer includes compression.

This supports equals(), hashCode() and compareTo(); two objects are equal if all their fields are, and the sort order is to minimise ad-lookup and HTML-bandwidth (ie by highest weight then smallest code, with ties being broken by code lexical ordering).


Field Summary
(package private)  java.lang.String code
          HTML code as 7-bit ASCII; non-null, non-zero length.
static int MAX_AD_CHARACTERS
          Maximum HTML code length in bytes/characters.
private static long serialVersionUID
          Our serialisation version.
(package private)  int weight
          Strictly positive weighting.
 
Constructor Summary
GenProps.SimpleAd(int adRelativeWeight, java.lang.String HTMLCode)
          Construct new simple ad details.
 
Method Summary
 int compareTo(GenProps.SimpleAd o)
          Provides total ordering, with primary sort by decreasing weight.
 boolean equals(java.lang.Object o)
          Equality depends on all fields.
 int hashCode()
          Hash depends on text as good source of variability.
protected  java.lang.Object readResolve()
          Deserialise: validate and eliminate duplicates coming off the wire.
 void validateObject()
          Validate fields/state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weight

final int weight
Strictly positive weighting.


code

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.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
Our serialisation version.

See Also:
Constant Field Values
Constructor Detail

GenProps.SimpleAd

GenProps.SimpleAd(int adRelativeWeight,
                  java.lang.String HTMLCode)
Construct new simple ad details.

Method Detail

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 text as good source of variability.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(GenProps.SimpleAd o)
Provides total ordering, with primary sort by decreasing weight. Full sort order is:
  1. decreasing weight, then
  2. increasing code length, then
  3. code lexical order.

Specified by:
compareTo in interface java.lang.Comparable<GenProps.SimpleAd>

readResolve

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

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

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

DHD Multimedia Gallery V1.57.21

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