001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.video; 020 021import lucee.commons.io.res.Resource; 022import lucee.commons.lang.StringUtil; 023import lucee.runtime.exp.PageException; 024import lucee.runtime.exp.PageRuntimeException; 025import lucee.runtime.type.util.ListUtil; 026 027public class VideoInputImpl implements VideoInput { 028 029 private Resource resource; 030 private String args=""; 031 private String path; 032 033 /** 034 * Constructor of the class 035 * @param resource 036 */ 037 public VideoInputImpl(Resource resource) { 038 this.resource=resource; 039 } 040 041 /** 042 * @see lucee.runtime.video.VideoInput#getResource() 043 */ 044 public Resource getResource() { 045 return resource; 046 } 047 048 /** 049 * @see lucee.runtime.video.VideoInput#setCommand(java.lang.String, java.util.List) 050 */ 051 public void setCommand(String path,java.util.List args) { 052 this.path=path; 053 try { 054 addArgs(ListUtil.listToList(args, " ")); 055 } catch (PageException pe) { 056 throw new PageRuntimeException(pe); 057 } 058 } 059 060 public void setCommand(String path,String[] args) { 061 this.path=path; 062 addArgs(ListUtil.arrayToList(args, " ")); 063 } 064 065 /** 066 * @see lucee.runtime.video.VideoInput#getCommandAsString() 067 */ 068 public String getCommandAsString() { 069 return path+" "+args; 070 } 071 072 private void addArgs(String args) { 073 if(StringUtil.isEmpty(this.args,true)) 074 this.args=args; 075 else 076 this.args+="; "+args; 077 078 } 079}