Package org.kohsuke.github
Class GHContent
- java.lang.Object
-
- org.kohsuke.github.GHContent
-
- All Implemented Interfaces:
Refreshable
public class GHContent extends Object implements Refreshable
A Content of a repository.- Author:
- Alexandre COLLIGNON
- See Also:
GHRepository#getFileContent(String)
-
-
Constructor Summary
Constructors Constructor Description GHContent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description GHContentUpdateResponsedelete(String message)Delete gh content update response.GHContentUpdateResponsedelete(String commitMessage, String branch)Delete gh content update response.StringgetContent()Deprecated.Useread()StringgetDownloadUrl()URL to retrieve the raw content of the file.StringgetEncodedContent()Deprecated.Useread()StringgetEncoding()Gets encoding.StringgetGitUrl()Gets git url.StringgetHtmlUrl()Gets html url.StringgetName()Gets name.GHRepositorygetOwner()Gets owner.StringgetPath()Gets path.StringgetSha()Gets sha.longgetSize()Gets size.StringgetType()Gets type.StringgetUrl()Gets url.booleanisDirectory()Is directory boolean.booleanisFile()Is file boolean.PagedIterable<GHContent>listDirectoryContent()List immediate children of this directory.protected voidpopulate()Fully populate the data by retrieving missing data.InputStreamread()Retrieves the actual bytes of the blob.voidrefresh()Fully populate the data by retrieving missing data.GHContentUpdateResponseupdate(byte[] newContentBytes, String commitMessage)Update gh content update response.GHContentUpdateResponseupdate(byte[] newContentBytes, String commitMessage, String branch)Update gh content update response.GHContentUpdateResponseupdate(String newContent, String commitMessage)Update gh content update response.GHContentUpdateResponseupdate(String newContent, String commitMessage, String branch)Update gh content update response.static GHContent[]wrap(GHContent[] contents, GHRepository repository)Wrap gh content [ ].-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.kohsuke.github.Refreshable
refresh
-
-
-
-
Method Detail
-
getOwner
public GHRepository getOwner()
Gets owner.- Returns:
- the owner
-
getType
public String getType()
Gets type.- Returns:
- the type
-
getEncoding
public String getEncoding()
Gets encoding.- Returns:
- the encoding
-
getSize
public long getSize()
Gets size.- Returns:
- the size
-
getSha
public String getSha()
Gets sha.- Returns:
- the sha
-
getName
public String getName()
Gets name.- Returns:
- the name
-
getPath
public String getPath()
Gets path.- Returns:
- the path
-
getContent
public String getContent() throws IOException
Deprecated.Useread()Retrieve the decoded content that is stored at this location.Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may trigger network activity, and can throw an IOException.
- Returns:
- the content
- Throws:
IOException- the io exception
-
getEncodedContent
public String getEncodedContent() throws IOException
Deprecated.Useread()Retrieve the base64-encoded content that is stored at this location.Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may trigger network activity, and can throw an IOException.
- Returns:
- the encoded content
- Throws:
IOException- the io exception
-
getUrl
public String getUrl()
Gets url.- Returns:
- the url
-
getGitUrl
public String getGitUrl()
Gets git url.- Returns:
- the git url
-
getHtmlUrl
public String getHtmlUrl()
Gets html url.- Returns:
- the html url
-
read
public InputStream read() throws IOException
Retrieves the actual bytes of the blob.- Returns:
- the input stream
- Throws:
IOException- the io exception
-
getDownloadUrl
public String getDownloadUrl() throws IOException
URL to retrieve the raw content of the file. Null if this is a directory.- Returns:
- the download url
- Throws:
IOException- the io exception
-
isFile
public boolean isFile()
Is file boolean.- Returns:
- the boolean
-
isDirectory
public boolean isDirectory()
Is directory boolean.- Returns:
- the boolean
-
populate
protected void populate() throws IOExceptionFully populate the data by retrieving missing data.Depending on the original API call where this object is created, it may not contain everything.
- Throws:
IOException- the io exception
-
listDirectoryContent
public PagedIterable<GHContent> listDirectoryContent() throws IOException
List immediate children of this directory.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
update
public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException
Update gh content update response.- Parameters:
newContent- the new contentcommitMessage- the commit message- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
update
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException
Update gh content update response.- Parameters:
newContent- the new contentcommitMessage- the commit messagebranch- the branch- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
update
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException
Update gh content update response.- Parameters:
newContentBytes- the new content bytescommitMessage- the commit message- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
update
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) throws IOException
Update gh content update response.- Parameters:
newContentBytes- the new content bytescommitMessage- the commit messagebranch- the branch- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
delete
public GHContentUpdateResponse delete(String message) throws IOException
Delete gh content update response.- Parameters:
message- the message- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
delete
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException
Delete gh content update response.- Parameters:
commitMessage- the commit messagebranch- the branch- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
wrap
public static GHContent[] wrap(GHContent[] contents, GHRepository repository)
Wrap gh content [ ].- Parameters:
contents- the contentsrepository- the repository- Returns:
- the gh content [ ]
-
refresh
public void refresh() throws IOExceptionFully populate the data by retrieving missing data. Depending on the original API call where this object is created, it may not contain everything.- Specified by:
refreshin interfaceRefreshable- Throws:
IOException- the io exception
-
-