@Test public void testParsePageNameWithNamespace() throws Exception { ParsedPageName name = ParsedPageName.parsePageName(wikiModel, "Talk:foo", null, false, false); assertThat(name.pagename).isEqualTo("foo"); assertThat(name.namespace).isEqualTo(wikiModel.getNamespace().getTalk()); }
@Nonnull public static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel, @Nonnull String pagename, INamespace.INamespaceValue namespace, boolean magicWordAllowed, boolean stripOffSection) { Object magicWord = null; String magicWordParameter = null; if (pagename.length() > 0 && pagename.charAt(0) == ':') { magicWordAllowed = false; if (pagename.length() > 1 && pagename.charAt(1) == ':') { return new ParsedPageName(namespace, pagename, false); } namespace = wikiModel.getNamespace().getMain(); pagename = pagename.substring(1); } if (stripOffSection) { int hashIndex = pagename.indexOf('#'); if (hashIndex != (-1)) { pagename = pagename.substring(0, hashIndex); } } final int index = pagename.indexOf(':'); if (index > 0) { String maybeNamespaceStr0 = pagename.substring(0, index); INamespace.INamespaceValue maybeNamespace = wikiModel.getNamespace().getNamespace(maybeNamespaceStr0); if (maybeNamespace != null) { return new ParsedPageName(maybeNamespace, pagename.substring(index + 1), true); } else if (magicWordAllowed) { magicWord = wikiModel.getMagicWord(maybeNamespaceStr0); if (magicWord != null) { magicWordParameter = pagename.substring(index + 1); if (magicWordParameter.length() != 0) { magicWordParameter = AbstractTemplateFunction.parseTrim(magicWordParameter, wikiModel); } } } } else if (magicWordAllowed && namespace.isType(INamespace.NamespaceCode.TEMPLATE_NAMESPACE_KEY)) { Object maybeMagicWord = wikiModel.getMagicWord(pagename); if (maybeMagicWord != null) { magicWord = maybeMagicWord; } } return new ParsedPageName(namespace, pagename, magicWord, magicWordParameter, true); }
ParsedPageName { @Nonnull public static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel, @Nonnull String pagename, INamespace.INamespaceValue namespace, boolean magicWordAllowed, boolean stripOffSection) { Object magicWord = null; String magicWordParameter = null; if (pagename.length() > 0 && pagename.charAt(0) == ':') { magicWordAllowed = false; if (pagename.length() > 1 && pagename.charAt(1) == ':') { return new ParsedPageName(namespace, pagename, false); } namespace = wikiModel.getNamespace().getMain(); pagename = pagename.substring(1); } if (stripOffSection) { int hashIndex = pagename.indexOf('#'); if (hashIndex != (-1)) { pagename = pagename.substring(0, hashIndex); } } final int index = pagename.indexOf(':'); if (index > 0) { String maybeNamespaceStr0 = pagename.substring(0, index); INamespace.INamespaceValue maybeNamespace = wikiModel.getNamespace().getNamespace(maybeNamespaceStr0); if (maybeNamespace != null) { return new ParsedPageName(maybeNamespace, pagename.substring(index + 1), true); } else if (magicWordAllowed) { magicWord = wikiModel.getMagicWord(maybeNamespaceStr0); if (magicWord != null) { magicWordParameter = pagename.substring(index + 1); if (magicWordParameter.length() != 0) { magicWordParameter = AbstractTemplateFunction.parseTrim(magicWordParameter, wikiModel); } } } } else if (magicWordAllowed && namespace.isType(INamespace.NamespaceCode.TEMPLATE_NAMESPACE_KEY)) { Object maybeMagicWord = wikiModel.getMagicWord(pagename); if (maybeMagicWord != null) { magicWord = maybeMagicWord; } } return new ParsedPageName(namespace, pagename, magicWord, magicWordParameter, true); } }
ParsedPageName { @Nonnull public static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel, @Nonnull String pagename, INamespace.INamespaceValue namespace, boolean magicWordAllowed, boolean stripOffSection) { Object magicWord = null; String magicWordParameter = null; if (pagename.length() > 0 && pagename.charAt(0) == ':') { magicWordAllowed = false; if (pagename.length() > 1 && pagename.charAt(1) == ':') { return new ParsedPageName(namespace, pagename, false); } namespace = wikiModel.getNamespace().getMain(); pagename = pagename.substring(1); } if (stripOffSection) { int hashIndex = pagename.indexOf('#'); if (hashIndex != (-1)) { pagename = pagename.substring(0, hashIndex); } } final int index = pagename.indexOf(':'); if (index > 0) { String maybeNamespaceStr0 = pagename.substring(0, index); INamespace.INamespaceValue maybeNamespace = wikiModel.getNamespace().getNamespace(maybeNamespaceStr0); if (maybeNamespace != null) { return new ParsedPageName(maybeNamespace, pagename.substring(index + 1), true); } else if (magicWordAllowed) { magicWord = wikiModel.getMagicWord(maybeNamespaceStr0); if (magicWord != null) { magicWordParameter = pagename.substring(index + 1); if (magicWordParameter.length() != 0) { magicWordParameter = AbstractTemplateFunction.parseTrim(magicWordParameter, wikiModel); } } } } else if (magicWordAllowed && namespace.isType(INamespace.NamespaceCode.TEMPLATE_NAMESPACE_KEY)) { Object maybeMagicWord = wikiModel.getMagicWord(pagename); if (maybeMagicWord != null) { magicWord = maybeMagicWord; } } return new ParsedPageName(namespace, pagename, magicWord, magicWordParameter, true); } ParsedPageName(INamespace.INamespaceValue namespace, String pagename, boolean valid);  ParsedPageName(INamespace.INamespaceValue namespace, String pagename, Object magicWord, String magicWordParameter, boolean valid); }
ParsedPageName { @Nonnull public static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel, @Nonnull String pagename, INamespace.INamespaceValue namespace, boolean magicWordAllowed, boolean stripOffSection) { Object magicWord = null; String magicWordParameter = null; if (pagename.length() > 0 && pagename.charAt(0) == ':') { magicWordAllowed = false; if (pagename.length() > 1 && pagename.charAt(1) == ':') { return new ParsedPageName(namespace, pagename, false); } namespace = wikiModel.getNamespace().getMain(); pagename = pagename.substring(1); } if (stripOffSection) { int hashIndex = pagename.indexOf('#'); if (hashIndex != (-1)) { pagename = pagename.substring(0, hashIndex); } } final int index = pagename.indexOf(':'); if (index > 0) { String maybeNamespaceStr0 = pagename.substring(0, index); INamespace.INamespaceValue maybeNamespace = wikiModel.getNamespace().getNamespace(maybeNamespaceStr0); if (maybeNamespace != null) { return new ParsedPageName(maybeNamespace, pagename.substring(index + 1), true); } else if (magicWordAllowed) { magicWord = wikiModel.getMagicWord(maybeNamespaceStr0); if (magicWord != null) { magicWordParameter = pagename.substring(index + 1); if (magicWordParameter.length() != 0) { magicWordParameter = AbstractTemplateFunction.parseTrim(magicWordParameter, wikiModel); } } } } else if (magicWordAllowed && namespace.isType(INamespace.NamespaceCode.TEMPLATE_NAMESPACE_KEY)) { Object maybeMagicWord = wikiModel.getMagicWord(pagename); if (maybeMagicWord != null) { magicWord = maybeMagicWord; } } return new ParsedPageName(namespace, pagename, magicWord, magicWordParameter, true); } ParsedPageName(INamespace.INamespaceValue namespace, String pagename, boolean valid);  ParsedPageName(INamespace.INamespaceValue namespace, String pagename, Object magicWord, String magicWordParameter, boolean valid); @Nonnull static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel,
                                                        @Nonnull String pagename, INamespace.INamespaceValue namespace,
                                                        boolean magicWordAllowed, boolean stripOffSection); @Override String toString(); String fullPagename(); @Override boolean equals(Object o); @Override int hashCode(); }
ParsedPageName { @Nonnull public static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel, @Nonnull String pagename, INamespace.INamespaceValue namespace, boolean magicWordAllowed, boolean stripOffSection) { Object magicWord = null; String magicWordParameter = null; if (pagename.length() > 0 && pagename.charAt(0) == ':') { magicWordAllowed = false; if (pagename.length() > 1 && pagename.charAt(1) == ':') { return new ParsedPageName(namespace, pagename, false); } namespace = wikiModel.getNamespace().getMain(); pagename = pagename.substring(1); } if (stripOffSection) { int hashIndex = pagename.indexOf('#'); if (hashIndex != (-1)) { pagename = pagename.substring(0, hashIndex); } } final int index = pagename.indexOf(':'); if (index > 0) { String maybeNamespaceStr0 = pagename.substring(0, index); INamespace.INamespaceValue maybeNamespace = wikiModel.getNamespace().getNamespace(maybeNamespaceStr0); if (maybeNamespace != null) { return new ParsedPageName(maybeNamespace, pagename.substring(index + 1), true); } else if (magicWordAllowed) { magicWord = wikiModel.getMagicWord(maybeNamespaceStr0); if (magicWord != null) { magicWordParameter = pagename.substring(index + 1); if (magicWordParameter.length() != 0) { magicWordParameter = AbstractTemplateFunction.parseTrim(magicWordParameter, wikiModel); } } } } else if (magicWordAllowed && namespace.isType(INamespace.NamespaceCode.TEMPLATE_NAMESPACE_KEY)) { Object maybeMagicWord = wikiModel.getMagicWord(pagename); if (maybeMagicWord != null) { magicWord = maybeMagicWord; } } return new ParsedPageName(namespace, pagename, magicWord, magicWordParameter, true); } ParsedPageName(INamespace.INamespaceValue namespace, String pagename, boolean valid);  ParsedPageName(INamespace.INamespaceValue namespace, String pagename, Object magicWord, String magicWordParameter, boolean valid); @Nonnull static ParsedPageName parsePageName(@Nonnull IWikiModel wikiModel,
                                                        @Nonnull String pagename, INamespace.INamespaceValue namespace,
                                                        boolean magicWordAllowed, boolean stripOffSection); @Override String toString(); String fullPagename(); @Override boolean equals(Object o); @Override int hashCode(); final INamespace.INamespaceValue namespace; final String pagename; final boolean valid; final Object magicWord; final String magicWordParameter; }