001package votorola.a.position; // Copyright 2013, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. 002 003import java.io.*; 004import java.net.*; 005import java.util.regex.*; 006import votorola.g.*; 007import votorola.g.lang.*; 008 009 010/** A particular revision of a pipe. 011 * 012 * @see <a href='http://reluk.ca/w/Category:Pipe' target='_top'>Category:Pipe</a> 013 */ 014public interface PipeRevision extends CoreRevision 015{ 016 017 018 /** The search pattern for the definitive template call in a pipe page. If the 019 * pattern matches, then it splits the wikitext of the call into groups based on the 020 * template parameter values, currently only (1) poll name. This method of 021 * extracting properties from a revision is required because SemanticMediawiki's data 022 * store does not attach properties to revisions, only to pages. 023 * 024 * @see ComponentPipeRevision#TEMPLATE_CALL_PATTERN 025 */ 026 static final Pattern TEMPLATE_CALL_PATTERN = Pattern.compile( "\\{\\s*\\{\\s*(?:\\w+ )?pipe\\s*" 027 + "(?:\\|\\s*.+?\\s*=\\s*.+?\\s*)*" // * 028 + "\\|\\s*poll\\s*=\\s*(.+?)\\s*" // POLL NAME 029 + "(?:\\|\\s*.+?\\s*=\\s*.+?\\s*)*" // * 030 + "\\}\\s*\\}" ); // * any other parameters are currently ignored 031 032 033 034 // ==================================================================================== 035 036 037 /** Thrown when a request cannot be met because the content of a page is not in the 038 * form required for a pipe. 039 */ 040 static final @ThreadSafe class MalformedContent extends IOException implements UserInformative 041 { 042 043 /** @param wikiScriptURI the base URL for script execution in the wiki, without a 044 * trailing slash (/). 045 */ 046 MalformedContent( final String message, final URI wikiScriptURI, final int rev ) 047 { 048 super( message + " | " + MediaWiki.revLoc(wikiScriptURI,rev) ); 049 } 050 051 } 052 053 054}