/** * Returns a namespace based on the value of that namespace defined by Wikipedia. * Never returns a disambiguation. * @param value the numeric value of the NameSpace as defined by Wikipedia * @return the corresponding NameSpace if it exists, else null */ public static NameSpace getNameSpaceByValue(int value){ if(value == 0) return NameSpace.ARTICLE; for (NameSpace v : NameSpace.values()){ if (value == v.getValue()) {return v;} } return null; } }
/** * <p> * Returns the id of the MediaWiki namespace of the revised page. The * meaning of this id depends on the configuration of the site that the page * is from. Usually, 0 is the main namespace. Even ids usually refer to * normal article pages while their odd successors represent the * corresponding talk namespace. * </p> * <p> * On a single MediaWiki site, the combination of page title and page * namespace is a key for a page at any given moment. However, users may * change the title and namespace by moving pages. The page id provides a * better clue to identify pages across history. * </p> * * @return integer namespace id */ @Override public int getNamespace() { return raw.getNamespace().getValue(); }
/** * <p> * Returns the id of the MediaWiki namespace of the revised page. The * meaning of this id depends on the configuration of the site that the page * is from. Usually, 0 is the main namespace. Even ids usually refer to * normal article pages while their odd successors represent the * corresponding talk namespace. * </p> * <p> * On a single MediaWiki site, the combination of page title and page * namespace is a key for a page at any given moment. However, users may * change the title and namespace by moving pages. The page id provides a * better clue to identify pages across history. * </p> * * @return integer namespace id */ @Override public int getNamespace() { return raw.getNamespace().getValue(); }
/** * Gets the list of all local page ids for lang = langId and a given namespace * @param lang * @return * @throws DaoException */ public TIntList getAllPageIdsInNamespace(Language lang, NameSpace ns) throws DaoException { TIntList pages = new TIntArrayList(); LiveAPIQuery.LiveAPIQueryBuilder builder = new LiveAPIQuery.LiveAPIQueryBuilder("ALLPAGES", lang); builder.setNamespace(ns.getValue()); LiveAPIQuery query = builder.build(); List<QueryReply> replyObjects = query.getValuesFromQueryResult(); for (QueryReply reply : replyObjects) { pages.add(reply.getId()); } return pages; }