All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.jlan.CmsJlanSearch Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (C) Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.jlan;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.alfresco.jlan.server.filesys.FileInfo;
import org.alfresco.jlan.server.filesys.SearchContext;

/**
 * This class represents the state of a search operation in a JLAN repository. It just contains
 * the list of all search results and an index into that list which points to the next result
 * which hasn't been fetched yet.

*/ public class CmsJlanSearch extends SearchContext { /** The files constituting the search result. */ private List m_files; /** The position of the next unfetched result. */ private int m_position; /** * Creates a new instance based on a given result list.

* * @param files the result list */ public CmsJlanSearch(List files) { m_files = new ArrayList(files); } /** * @see org.alfresco.jlan.server.filesys.SearchContext#getResumeId() */ @Override public int getResumeId() { return m_position; } /** * @see org.alfresco.jlan.server.filesys.SearchContext#hasMoreFiles() */ @Override public boolean hasMoreFiles() { return m_position < m_files.size(); } /** * @see org.alfresco.jlan.server.filesys.SearchContext#nextFileInfo(org.alfresco.jlan.server.filesys.FileInfo) */ @Override public boolean nextFileInfo(FileInfo info) { try { CmsJlanNetworkFile file = nextFile(); if (file == null) { return false; } info.copyFrom(file.getFileInfo()); return true; } catch (IOException e) { // shouldn't normally happen throw new RuntimeException(e); } } /** * @see org.alfresco.jlan.server.filesys.SearchContext#nextFileName() */ @Override public String nextFileName() { return nextFile().getName(); } /** * @see org.alfresco.jlan.server.filesys.SearchContext#restartAt(org.alfresco.jlan.server.filesys.FileInfo) */ @Override public boolean restartAt(FileInfo info) { return false; } /** * @see org.alfresco.jlan.server.filesys.SearchContext#restartAt(int) */ @Override public boolean restartAt(int resumeId) { return false; } /** * Returns the next file object in the search result.

* * @return the next file object */ protected CmsJlanNetworkFile nextFile() { if (!hasMoreFiles()) { return null; } CmsJlanNetworkFile file = m_files.get(m_position); m_position += 1; return file; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy