java.lang.Object
i2p.susi.dns.BaseBean
i2p.susi.dns.AddressbookBean
- Direct Known Subclasses:
NamingServiceBean
Bean for managing I2P address books. Provides functionality for loading, filtering, and managing address entries.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final LogLogger instance.private Map<String, Properties> Parsed #! properties per hostname, built once per load.private PropertiesSubscriptions by name.protected intBeginning index for pagination.protected StringThe address book name.protected StringThe category filter string.protected final LinkedList<String> List of entries marked for deletion.protected StringThe destination.private static final intSubscriptions listed on one page.protected intEnding index for pagination.protected AddressBean[]Array of address entries.protected StringThe filter string.protected StringThe hostname.protected StringThe search string.protected static final Comparator<AddressBean> Comparator for sorting addresses.private static final String[]Valid category names.Fields inherited from class BaseBean
_context, action, lastSerial, method, PROP_PW_ENABLE, properties, serialModifier and TypeFieldDescriptionprotected final I2PAppContextThe I2P application context.protected StringThe current action.protected StringThe last serial number for CSRF.protected StringThe HTTP method.static final StringProperty for password enable.protected final PropertiesThe configuration properties.protected StringThe serial number.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprotected StringFormat a message about filtered addressbook size, and the number of displayed entries addressbook.jsp catches the case where the whole book is empty.getBegin()The clamped first displayed entry index, as a string for the JSP.protected intThe first displayed entry index, clamped to the result set.getBook()This always returns a valid book, non-null.The category filter, set when the search filter names a category.The destination for the add or edit form, as entered.Returns the display name for the address book.getEnd()The clamped last displayed entry index, as a string for the JSP.protected intThe last displayed entry index, clamped to the result set.Returns the address entries.Returns the file name for the address book.The search filter narrowing the displayed entries.The hostname for the add or edit form, as entered.Load addressbook and apply filter, returning messages about this.Perform actions, returning messages about this.intGets the beginning index into results for display purposes.The index of the first entry in the result set, as a string.The index of the last entry in the result set, as a string.Returns the search string.protected intGets the total count of filtered results for pagination display.booleanReturns whether a filter is active.booleanReturns whether the address book is empty.booleanReturns whether the address book is not empty.protected booleanChecks if entries are pre-filtered.booleanBecause the following from addressbook.jsp fails parsing in the new EL: javax.el.ELException: Failed to parse the expression Can't figure out why, so just replace it with book.validBook:private voidloadPropertiesFromFile(AddressBean bean, String hostname) Load properties for a hostname from the raw hosts.txt file.private Map<String, Properties> Parse the #! properties from the raw hosts.txt file in one pass.protected intThe number of entries in the current result set.private voidsave()Writes the subscriptions back to the file.voidSet the page start index from a form string, ignoring garbage.voidSet the address book to display, normalizing unknown names to "router".voidsetDestination(String destination) Set the destination for the add or edit form.voidSet the page end index from a form string, ignoring garbage.voidSet the search filter; "none" clears it, and a category name selects that category.voidsetHostname(String hostname) Set the hostname for the add or edit form.voidsetMarkedForDeletion(String name) Marks an entry for deletion.voidsetResetDeletionMarks(String dummy) Resets the deletion marks.voidSets the search string.protected intThe total number of entries in the book.Methods inherited from class BaseBean
_t, _t, _t, addressbookDir, configFile, debug, getAction, getSerial, getTheme, getThemeName, getThemes, isOverrideCssActive, loadConfig, ngettext, reload, setAction, setSerial, storeMethod, useSoraFont, warnModifier and TypeMethodDescriptionprotected static StringTranslate a string.protected static StringTranslate a string with one parameter.protected static StringTranslate a string with two parameters.protected FileReturns the addressbook directory.protected FileThe addressbook configuration file.protected voidLog a debug message.Get the action.Generate a new random serial for CSRF protection and clear the pending action.getTheme()Returns the theme path.The configured console theme name.String[]Get all themes.booleanDetermine if a user-provided override.css file is active.protected voidLoads the configuration if needed.protected static StringTranslate a string with plural form (ngettext).protected voidreload()Reloads the configuration from file.voidSets the action.voidSets the serial.voidstoreMethod(String method) Store the HTTP method.booleanChecks if Sora font should be used.protected voidLog a warning message.
Field Details
_log
Logger instance.book
The address book name.filter
The filter string.search
The search string.hostname
The hostname.destination
The destination.category
The category filter string.VALID_CATEGORIES
Valid category names.beginIndex
protected int beginIndexBeginning index for pagination.endIndex
protected int endIndexEnding index for pagination.addressbook
Subscriptions by name._propsByHost
Parsed #! properties per hostname, built once per load.deletionMarks
List of entries marked for deletion.sorter
Comparator for sorting addresses.DISPLAY_SIZE
private static final int DISPLAY_SIZESubscriptions listed on one page.- See Also:
entries
Array of address entries.
Constructor Details
AddressbookBean
public AddressbookBean()Creates an empty addressbook bean.
Method Details
getSearch
setSearch
isHasFilter
public boolean isHasFilter()Returns whether a filter is active.- Returns:
- true if a filter is active
isIsEmpty
public boolean isIsEmpty()Returns whether the address book is empty.- Returns:
- true if the address book is empty
isNotEmpty
public boolean isNotEmpty()Returns whether the address book is not empty.- Returns:
- true if the address book is not empty
getFileName
loadPropertiesFromFile
Load properties for a hostname from the raw hosts.txt file. This parses the #! format for properties.- Parameters:
bean- the AddressBean to set properties onhostname- the host whose hosts.txt entry is to be parsed
parsePropertiesFromFile
Parse the #! properties from the raw hosts.txt file in one pass. Called once per load and reused for every entry.- Returns:
- the map of hostname to parsed properties, may be empty
getDisplayName
Returns the display name for the address book.- Returns:
- the display name
getEntries
getBook
setBook
Set the address book to display, normalizing unknown names to "router".- Parameters:
book- the book name to set
getLoadBookMessages
Load addressbook and apply filter, returning messages about this.- Returns:
- messages about loading the address book
generateLoadMessage
Format a message about filtered addressbook size, and the number of displayed entries addressbook.jsp catches the case where the whole book is empty.- Returns:
- message about loading
getMessages
Perform actions, returning messages about this.- Returns:
- messages about the performed actions
save
Writes the subscriptions back to the file.- Throws:
IOException- if the file cannot be written
getFilter
The search filter narrowing the displayed entries.- Returns:
- the filter string
isValidBook
public boolean isValidBook()Because the following from addressbook.jsp fails parsing in the new EL: javax.el.ELException: Failed to parse the expression Can't figure out why, so just replace it with book.validBook:
This always returns true anyway, because<c:if test="${book.master || book.router || book.published || book.private}">getBook()always returns a valid book.- Returns:
- true if the book is one of router, master, local, published or private
setFilter
Set the search filter; "none" clears it, and a category name selects that category.- Parameters:
filter- filter string to set
getDestination
The destination for the add or edit form, as entered.- Returns:
- the destination string
setDestination
Set the destination for the add or edit form.- Parameters:
destination- the destination string to store, stripped of any HTML
getCategoryFilter
The category filter, set when the search filter names a category.- Returns:
- the category filter string
getHostname
The hostname for the add or edit form, as entered.- Returns:
- the hostname string
setResetDeletionMarks
Resets the deletion marks.- Parameters:
dummy- unused, required by the JavaBeans setter convention
setMarkedForDeletion
Marks an entry for deletion.- Parameters:
name- the name of the entry to mark for deletion
setHostname
Set the hostname for the add or edit form.- Parameters:
hostname- the hostname string to store, stripped of any HTML
getBeginInt
protected int getBeginInt()The first displayed entry index, clamped to the result set.- Returns:
- the beginning index
getBegin
The clamped first displayed entry index, as a string for the JSP.- Returns:
- the beginning index as string
getPageBegin
public int getPageBegin()Gets the beginning index into results for display purposes. Returns the actual page start index, not clamped toresultSize().- Returns:
- the page start index (0-based)
setBegin
Set the page start index from a form string, ignoring garbage.- Parameters:
s- the beginning index as string
getEndInt
protected int getEndInt()The last displayed entry index, clamped to the result set.- Returns:
- the ending index
getEnd
The clamped last displayed entry index, as a string for the JSP.- Returns:
- the ending index as string
getResultBegin
The index of the first entry in the result set, as a string.- Returns:
- beginning index into results
getResultEnd
The index of the last entry in the result set, as a string.- Returns:
- ending index into results
setEnd
Set the page end index from a form string, ignoring garbage.- Parameters:
s- the ending index as string
isPrefiltered
protected boolean isPrefiltered()Checks if entries are pre-filtered.- Returns:
- true if pre-filtered
resultSize
protected int resultSize()The number of entries in the current result set.- Returns:
- the size of the lookup result
getTotalFilteredCount
protected int getTotalFilteredCount()Gets the total count of filtered results for pagination display. Subclasses can override to return the count before manual pagination.- Returns:
- the total count of filtered results
totalSize
protected int totalSize()The total number of entries in the book.- Returns:
- the total size of the address book