Template.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Tobias Kaminsky
  5. * Copyright (C) 2018 Tobias Kaminsky
  6. * Copyright (C) 2018 Nextcloud GmbH.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. package com.owncloud.android.datamodel;
  22. import org.parceler.Parcel;
  23. import java.util.Locale;
  24. /**
  25. * Template for creating a file from it via RichDocuments app
  26. */
  27. @Parcel
  28. public class Template {
  29. public int id;
  30. public String name;
  31. public String thumbnailLink;
  32. public Type type;
  33. public String extension;
  34. public Template() {
  35. // empty constructor
  36. }
  37. public Template(int id, String name, String thumbnailLink, Type type, String extension) {
  38. this.id = id;
  39. this.name = name;
  40. this.thumbnailLink = thumbnailLink;
  41. this.type = type;
  42. this.extension = extension;
  43. }
  44. public enum Type {
  45. DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN
  46. }
  47. public static Type parse(String type) {
  48. switch (type.toLowerCase(Locale.US)) {
  49. case "document":
  50. return Type.DOCUMENT;
  51. case "spreadsheet":
  52. return Type.SPREADSHEET;
  53. case "presentation":
  54. return Type.PRESENTATION;
  55. default:
  56. return Type.UNKNOWN;
  57. }
  58. }
  59. public int getId() {
  60. return this.id;
  61. }
  62. public String getName() {
  63. return this.name;
  64. }
  65. public String getThumbnailLink() {
  66. return this.thumbnailLink;
  67. }
  68. public Type getType() {
  69. return this.type;
  70. }
  71. public String getExtension() {
  72. return this.extension;
  73. }
  74. public void setId(int id) {
  75. this.id = id;
  76. }
  77. public void setName(String name) {
  78. this.name = name;
  79. }
  80. public void setThumbnailLink(String thumbnailLink) {
  81. this.thumbnailLink = thumbnailLink;
  82. }
  83. public void setType(Type type) {
  84. this.type = type;
  85. }
  86. public void setExtension(String extension) {
  87. this.extension = extension;
  88. }
  89. }